2011-08-25 98 views
0

我是新来的编码,并想知道我可能如何能够设置一条警报消息条件语句。所以我有这个至今:UIAlertView条件statmenst(如果其他??)

mapView.showsUserLocation = YES; 

NSString *title = [[NSString alloc] initWithFormat: 
        @"Alert"]; 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: title message: @"I would like to use your location." delegate:self cancelButtonTitle:@"Allow" otherButtonTitles:@"Don't Allow", nil]; 

基本上我想如果让选择,运行showuserlocation ......否则NO把一个if else语句中 。

我该怎么做?

谢谢...

回答

0

不要自己这样做。只需运行你的showUserLocation方法。如果用户尚未授予您应用的权限,系统会自动提示用户允许该应用访问有关其当前位置的详细信息。

只要您的应用尝试访问任何基于位置的功能,操作系统就会为您执行此操作。