我在让 UIAlert 返回布尔值时遇到了麻烦,而且我真的在网上找不到任何东西,所以我希望你们能帮忙。首先,这是应用程序的基本设置。基本上,当用户单击“单击”按钮时,会弹出一个警报,选择“是”和“否”。到目前为止,这是我为按钮设置的代码:
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];
我怎样才能准确地使用完成选项来返回一个布尔值?