我是编码的新手,并想知道如何为警报消息设置条件语句。所以到目前为止我有这个:
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];
基本上我想在其中加上if else语句。 如果选择了allow,则运行showuserlocation ...否NO。
我该怎么做?
...谢谢
答案 0 :(得分:0)
不要自己这样做。只需运行showUserLocation
方法即可。如果用户尚未授予您的应用权限,系统会自动提示用户允许该应用访问有关其当前位置的详细信息。
只要您的应用尝试访问任何基于位置的功能,操作系统就会为您执行此操作。