2016-04-12 14 views
0

シンプルなアラートを作成していますが、このエラーが表示されています。UIAlertControllerが最新のXcodeでエラーを表示しています

import UIKit 

class ViewController: UIViewController { 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     // Do any additional setup after loading the view, typically from a nib. 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 

    @IBAction func but (action:UIButton) { 

     let alertcontroller = UIAlertController(title: "Title", message: "message", preferredStyle: .Alert) 

     let alert = UIAlertAction(title: "Action titel", style: .Default, handler: nil) 
     alertcontroller.addAction(alert) 
     self.presentedViewController (alertcontroller, animated:true, completion: nil) 

      } 

} 

it's showing this error **strong text**

+1

と私のためにどのような作品であり、 'self.presentViewController'の代わりに.presentedViewController'を実行します。 – dan

答えて

1

それがpresentViewController(...)なければならない代わりに、presentedViewController(...)の

0

これは、あなたが `自己を書いスウィフト

@IBAction func but (action:UIButton) 
{ 
     let alert = UIAlertController(title: "Title", message:"message", preferredStyle: .Alert) 
     alert.addAction(UIAlertAction(title: "Okay.", style: .Default) { _ in }) 

     //Show 
     dispatch_async(dispatch_get_main_queue(),^{ 
     self.presentViewController(alert, animated: true){} 
     }); 
} 
関連する問題