2012-12-12 88 views

回答

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用户当前的位置问
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.