【发布时间】:2016-01-24 05:46:03
【问题描述】:
我在让 UIAlert 返回布尔值时遇到了麻烦,而且我在网上找不到任何东西,所以我希望你们能帮忙。首先,这是app 的基本设置。基本上,当用户单击“单击”按钮时,会弹出一个警报,选择“是”和“否”。到目前为止,这是我为按钮设置的代码:
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"Choose"
message:@"Answer the question" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *defaultAction= [UIAlertAction actionWithTitle:@"YES"
style:UIAlertActionStyleDefault
handler:nil];
UIAlertAction *noAction= [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:defaultAction];
[alert addAction:noAction];
[self presentViewController:alert animated:YES completion:nil];
我怎样才能准确地使用完成选项来返回一个布尔值?
【问题讨论】:
-
你真的什么都找不到?真的吗?下面的题目怎么样? stackoverflow.com/questions/28831468/…我可以找到更多。
-
您不能从动作处理程序返回任何内容,但您可以设置一个变量,以便在控制器关闭后检查。
标签: ios objective-c uikit uialertcontroller uialertaction