核心位置警报

时间:2012-12-12 11:54:01

标签: iphone ios alert core-location

我在O'Reilly教程中看到了以下警告:

  1. http://answers.oreilly.com/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=125
  2. http://answers.oreilly.com/uploads/monthly_10_2009/post-48-125435525931_thumb.jpg
  3. 我不明白如何触发这些警报。请你告诉我的意见?该应用程序使用ios6

2 个答案:

答案 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];
}

请阅读CLLocationManager Class Reference了解详情

答案 1 :(得分:0)

好吧,它非常简单。它被称为UIAlertView并且非常常见,用于发出通知。它们应该用于通知用户某些东西而不是用于交互。

明智的编码,这是一些基本的设置文本:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert Body" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];

显示提醒:

[alert show];

如果您想要其他按钮标题,则需要将delegate设置为self,并将.h文件符合UIAlertViewDelegateHere Is The Reference To The Delegate并且您基本上希望实现clickedButtonAtIndex:方法并使用索引来找出用户按下哪个按钮并执行操作。

Do not misuse alert views.