Unable to choose order of buttons in UIAlertController

时间秒杀一切 提交于 2019-11-30 12:44:07

My solution to this was to use the .Default style instead of .Cancel for the cancelAction.

Since iOS9 there is a preferredAction property on UIAlertController. It places action on right side. From docs:

When you specify a preferred action, the alert controller highlights the text of that action to give it emphasis. (If the alert also contains a cancel button, the preferred action receives the highlighting instead of the cancel button.)

The action object you assign to this property must have already been added to the alert controller’s list of actions. Assigning an object to this property before adding it with the addAction: method is a programmer error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!