我在O'Reilly教程中看到了以下警告:
答案 0 :(得分:1)
这是访问当前位置时的提醒,当您使用CLLocationManager
访问用户当前位置时会自动询问-(void)getLocation
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLLocationAccuracyHundredMeters;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
NSLog(@"eee%f",locationManager.location.coordinate.latitude);
// Start updating location changes.
[locationManager startUpdatingLocation];
}
- (void)startUpdatingCurrentLocation
{
//NSLog(@"STARTUPDATELOCATION");
// if location services are restricted do nothing
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ||
[CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted )
{
return;
}
// if locationManager does not currently exist, create it
if (!locationManager)
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
locationManager.distanceFilter = 10.0f; // we don't need to be any more accurate than 10m
}
[locationManager startUpdatingLocation];
// [self showCurrentLocationSpinner:YES];
}
答案 1 :(得分:0)
好吧,它非常简单。它被称为UIAlertView
并且非常常见,用于发出通知。它们应该用于通知用户某些东西而不是用于交互。
明智的编码,这是一些基本的设置文本:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert Body" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
显示提醒:
[alert show];
如果您想要其他按钮标题,则需要将delegate
设置为self
,并将.h文件符合UIAlertViewDelegate
。 Here Is The Reference To The Delegate并且您基本上希望实现clickedButtonAtIndex:
方法并使用索引来找出用户按下哪个按钮并执行操作。