gpt4 book ai didi

ios - 当点击注释时用户位置的脉冲将显示警报

转载 作者:行者123 更新时间:2023-11-29 00:47:19 26 4
gpt4 key购买 nike

我已经能够通过使用 https://github.com/TransitApp/SVPulsingAnnotationView 来增加用户位置注释的半径
现在,如果我在 map 上放置一个自定义注释,并且如果这个脉冲命中那个符号,我想显示一些东西,比如一个 AlertView。 我该怎么做?以下是我更改默认 userLocation 注释的方法。

- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id<MKAnnotation>)annotation {

if (annotation==(mapView.userLocation)) {

static NSString *identifier = @"currentLocation";
SVPulsingAnnotationView *pulsingView = (SVPulsingAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

if(pulsingView == nil) {
pulsingView = [[SVPulsingAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
pulsingView.pulseScaleFactor= 40.0;//Change pulseScaleFactor as required
pulsingView.outerPulseAnimationDuration = 1.5;
pulsingView.canShowCallout = YES;
pulsingView.centerOffset = CGPointMake(0, 250);
}

return pulsingView;

}
else return nil;
}

最佳答案

尝试将地理围栏添加到该注释,并为脉冲注释指定半径。

    NSString *title = "annotationTitle";
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(annotationLatitude, annotationLongitude);
CLLocationDistance regionRadius = [@"radius" doubleValue]; // Here radius is in meters, say @"500"
CLCircularRegion *geofence = [[CLCircularRegion alloc] initWithCenter:centerCoordinate radius:regionRadius identifier:title];

[_locationManager startMonitoringForRegion:geofence];

当您的位置/脉冲注释进入该注释的指定半径时,将触发两个重要的方法。

    //triggers when entering in region
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{

UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Your Title" message:@"YourMessage" delegate:APP_DELEGATE cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
}

//triggers when exiting from region
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Your Title" message:@"YourMessage" delegate:APP_DELEGATE cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
}

这看起来就像脉冲命中注释然后触发警报。

希望这对您有所帮助。

关于ios - 当点击注释时用户位置的脉冲将显示警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38477713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com