UIAlertView 条件统计(如果是其他??)
我是编码新手,想知道如何为警报消息设置条件语句。所以到目前为止我已经这样了:
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 语句。 如果选择允许,则运行 showuserlocation...否则不。
我怎样才能做到这一点?
谢谢...
I'm new to coding and was wondering how I might be able to set a conditional statement for an alert message. So I have this so far:
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];
Basically I want to put an if else statement in.
if allow is selected, run showuserlocation... else NO.
How can I do that?
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要自己这样做。只需运行您的
showUserLocation
方法即可。如果用户尚未授予您的应用程序权限,系统将自动提示用户允许应用程序访问有关其当前位置的详细信息。一旦您的应用程序尝试访问任何基于位置的功能,操作系统就会为您执行此操作。
Don't do this yourself. Just run your
showUserLocation
method. The user will automatically be prompted to allow the app to access details about their current location, if they haven't already granted permission for your app.The OS does this for you, as soon as your app attempts to access any location-based features.