0

Apple's iOS UX guidelines show the following example:

Example alert

...where:

  • 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.

  • 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.

Source: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Alerts.html

However, it does not seem possible to implement this guidance with the current iOS APIs (testing on iOS 9 with Swift). Here's one attempt. But I've tried varying the order of adding the alert actions, and changing which action is .Default vs. .Cancel style. No combination appears to work.

@IBAction func showAlertAction(sender: AnyObject)
{
    let title = "An Alert that Offers Two Alternatives Is Easy for People to Use"

    let alertViewController = UIAlertController(title: title, message: nil, preferredStyle: UIAlertControllerStyle.Alert)

    let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: { (alert :UIAlertAction!) -> Void in

        print("'Cancel' tapped")
    })

    alertViewController.addAction(cancelAction)

    let safeChoiceAction = UIAlertAction(title: "Safe Choice", style: UIAlertActionStyle.Default, handler: { (alert :UIAlertAction!) -> Void in

        print("'Safe Choice' tapped")
    })

    alertViewController.addAction(safeChoiceAction)

    self.presentViewController(alertViewController, animated: true, completion: nil)
}

Result:

enter image description here

Daniel
  • 8,794
  • 4
  • 48
  • 71
  • 1
    Yeah, i guess you just can't do it ! i've went throw the same thing. but at the end they wouldn't reject the app so ! – AaoIi Oct 10 '15 at 01:15
  • 1
    This is apparently an intentional change by Apple: http://stackoverflow.com/questions/29590534/ios-uialertcontroller-bold-button-changed-in-8-3 – jamesk Oct 10 '15 at 06:29

0 Answers0