我在 O'Reilly 教程中看到了以下警报:
- http://answers.oreilly.com/index.php?app=core&module=attach§ion=attach&attach_rel_module=post&attach_id=125
- http://answers.oreilly.com/uploads/monthly_10_2009/post-48-125435525931_thumb.jpg
我不明白如何触发这些警报。请问你能通知我吗?使用ios6的应用
我在 O'Reilly 教程中看到了以下警报:
我不明白如何触发这些警报。请问你能通知我吗?使用ios6的应用
这是访问您当前位置时的警报,当您使用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];
}
只需阅读CLLocationManager 类参考了解更多信息
好吧,它非常简单。它被称为一个UIAlertView
并且非常常见的用于提供通知。它们应该用于通知用户一些事情,而不是太多的交互。
编码明智,这里是一些基本的设置文本:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert Body" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
要显示警报:
[alert show];
如果您想要其他按钮标题,则需要将 .h 文件中的 to 设置delegate
为self
并符合UIAlertViewDelegate
. 这是对委托的引用,您基本上想要实现该clickedButtonAtIndex:
方法并使用索引来找出用户按下了哪个按钮并执行操作。