UIAlertView: Where the cancel button should be?

流过昼夜 提交于 2019-12-20 10:24:44

问题


The alertviews in the iOS:

  • Install App OTA: the cancel button is on the LEFT.
  • Delete an App: the cancel button is on the RIGHT.

Where the cancel button should be?


回答1:


From Human Interface Guideline:

In a two-button alert that proposes a potentially risky action, the button that cancels the action should be on the right (and light-colored).

In a two-button alert that proposes a benign action that people are likely to want, the button that cancels the action should be on the left (and dark-colored).




回答2:


As per Apple Place buttons where people expect them. In general, buttons people are most likely to tap should be on the right. Cancel buttons should always be on the left. https://developer.apple.com/ios/human-interface-guidelines/ui-views/alerts/




回答3:


If you set the text for the cancel button in the initializer, iOS will take care of this for you.

As the Human Interface Guidelines say:

In a two-button alert that proposes a potentially risky action, the button that cancels the action should be on the right (and light-colored).

Although, in practice, you may be labeling your buttons with something other than the generic label. (I have Yes/No) alerts in many circumstances. As your example from Apple shows, this part of the HIG won't be a deal breaker for your app.




回答4:


The definition in was slightly updated (no dark-light colored references):

  1. When the most likely button performs a nondestructive action, it should be on the right in a two-button alert. The button that cancels this action should be on the left.
  2. When the most likely button performs a destructive action, it should be on the left in a two-button alert. The button that cancels this action should be on the right.



回答5:


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue"];

The cancel button will be on the left side of the screen in this case which is the default case.



来源:https://stackoverflow.com/questions/6582795/uialertview-where-the-cancel-button-should-be

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