【发布时间】:2016-06-22 18:00:23
【问题描述】:
我想更改警报操作按钮的顺序,根据代码我尝试了所有可能性,但不允许我更改顺序。
在这里查看我的代码
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"alert" message:@"My alert message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:yesButton];
[alertController addAction:noButton];
[self presentViewController:alertController animated:YES completion:nil];
这会给我以下结果。我想更改右手边的 Cancel button 和左手边的 OK button。
感谢您的宝贵时间。
【问题讨论】:
-
只有当另一个选项是破坏性操作时,取消按钮才应该在右侧,在这种情况下,您应该使用
UIAlertActionStyleDestructive进行该操作。当右侧为UIAlertActionStyleDefault时,将其放在左侧是正确的行为
标签: ios uialertcontroller