2012-08-15 37 views
0

在我的應用程序中,如果位置服務處於關閉狀態,它會提示用戶:打開位置服務以允許「MyAPP」確定您的位置。iOS CLLocationManager打開位置服務

兩個選項按鈕是設置和取消。

當用戶按下取消按鈕時如何處理?

是否有任何delgate方法來處理取消按鈕按?

+2

你不能做任何東西,除了顯示這樣的消息: 「您需要啓用定位服務,才能使用blablabla」 。 – aforaudrey 2012-08-15 19:18:37

回答

0

也許這可能適用於你想要的。

首先,符合頭文件中的UIAlertViewDelegate協議。

然後有一個你可以實現的委託方法。 //通過UIAlertView中按鈕名稱

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    // if the alert view that appeared has titled "Location Denied" and user pressed on cancel button (cancel button is button at index 0) 
    if(alertView.title isEqualToString:@"Location Denied"] && buttonIndex == 0) 
    { 
     // do something 
    } 
} 
1

你可以訪問你按下哪個按鈕*

- (空)alertView:(UIAlertView中*)alertView clickedButtonAtIndex:(NSInteger的)buttonIndex

{ 

NSString * title = [alertView buttonTitleAtIndex:buttonIndex];

如果([標題isEqualToString:@ 「取消」])

{ 

    } 

}

相關問題