iOSのバージョンによってはUIAlertControllerのボタンの並びが変になるかもしれない
古いiOSだとUIAlertControllerにaddActionした順に左から表示されるっぽい。 たまたま古いテスト機で触ってて違和感があって発見。
こんなコードが
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) showDialog() } func showDialog() { let message = "OK,キャンセルの順" // ↓ここのaddActionする順番を逆にしたりすると let alert = UIAlertController(title: "title", message: message, preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)) presentViewController(alert, animated: true, completion: nil) } }
iOS8.4
iOS8.1
iOS8.1だと足した順に左からになってて、8.4だと常にOKが右に来てる。
シミュレータではiOS9.0を動かしてたので、たまたま古いiPhone5でテストしなかったら気づかなかった。
こういうの他にもありそうで怖い。