UIAlertActionを別クラスから呼び出したいのですがself.presentViewController(alert, animated: true, completion: nil)の関係?で呼び出し元で描画してくれません。
このself.presentViewControllerをViewControllerに反映するにはどうすればよいでしょうか?
お願い致します。
Swift
1class Sub: UIViewController { 2 3func alert() { 4 let alert = UIAlertController(title: "abc", message: "", preferredStyle: .Alert) 5 alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)) 6 self.presentViewController(alert, animated: true, completion: nil) 7} 8 9------------------------------------ 10[ViewControllerクラス] 11import UIKit 12.... 13class ViewController: UIViewController { 14...... 15let sub = Sub() 16override func viewDidLoad() { 17 super.viewDidLoad() 18 sub.alert() 19}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/06 05:43