【发布时间】:2015-08-27 22:03:27
【问题描述】:
我的印象是,如果正常操作是破坏性操作,而另一个是其 UIAlertController 中的取消操作,那么破坏性操作应该在左侧,而取消操作应该在右侧。
如果正常动作没有破坏性,那么正常动作应该在右边,取消应该在左边。
也就是说,我有以下内容:
var confirmLeaveAlert = UIAlertController(title: "Leave", message: "Are you sure you want to leave?", preferredStyle: .Alert)
let leaveAction = UIAlertAction(title: "Leave", style: .Destructive, handler: {
(alert: UIAlertAction!) in
//Handle leave
}
)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
confirmLeaveAlert.addAction(leaveAction)
confirmLeaveAlert.addAction(cancelAction)
self.presentViewController(confirmLeaveAlert, animated: true, completion: nil)
我的印象是,如果我先添加leaveAction,那么cancelAction 即leaveAction 将是左侧的按钮。此情况并非如此。我也尝试以相反的顺序添加按钮,这也导致按钮以相同的顺序添加。
我错了吗?有没有办法做到这一点?
【问题讨论】:
标签: ios swift ios8 uialertcontroller