【发布时间】:2015-12-28 13:19:32
【问题描述】:
我正在将项目 IOS8 编辑到 IOS 9,我很难找到在 IOS 9 中告诉我他已“弃用”的 UIAlertView 我现在用 UIAlertController 替换了 UIAlertView 但我发现了其他错误, 谁能帮我解决这个问题? 谢谢!
这是我的代码
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
Annotation *myAnnotation = (Annotation *)view.annotation;
CLLocationCoordinate2D currentUserCoords = CLLocationCoordinate2DMake(myMapView.userLocation.coordinate.latitude, myMapView.userLocation.coordinate.longitude);
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(myAnnotation.coordinate.latitude, myAnnotation.coordinate.longitude);
if ((CLLocationCoordinate2DIsValid(coord))&&(CLLocationCoordinate2DIsValid(currentUserCoords))) {
Annotation *ann = (Annotation *)view.annotation;
selectedCoords = ann.coordinate;
NSString *strTitle = @"GPS";
NSString *strMess = @"Close and open in maps?";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle
message:strMess
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention"
message:@"It was not possible to determine the current location.\nPlease check in: /nSettings> Privacy> Location"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinView"];
if (!pinView) {
pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinView"];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeInfoLight];
if ([UIDevice currentDevice].systemVersion.intValue >= 7)
pinView.tintColor = [UIColor colorWithRed:0.743 green:0.609 blue:0.432 alpha:1.000];
} else {
pinView.annotation = annotation;
}
return pinView;
}
我试图用 UIAlertController 替换 UIAlertView。 这是结果
【问题讨论】:
标签: uialertview uialertcontroller