2012-12-12 125 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.