のために働く
func showDeleteWarningAndDeleteEntity() {
dispatch_async(dispatch_get_main_queue(), {
let deleteController = UIAlertController(title: "Delete car", message: "Are you sure?", preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) {
(action) in
}
let okACtion = UIAlertAction(title: "Yes", style: .Destructive) {
(action) in
//some network stuff happens here...
self.dismissViewControllerAnimated(true, completion: nil)
}
deleteController.addAction(okACtion)
deleteController.addAction(cancelAction)
self.presentViewController(deleteController, animated: true, completion: nil)
})
}
希望
にコードを記述する理由はありません
dispatch_async(dispatch_get_main_queue(), { //write your code here
})
ab oveコードはメインスレッドの作業に使用されます。しかし、ここであなたはすでにメインスレッドにいます。
ここでの問題は、あなたはそれがself
で却下することができます唯一のよう
self
コントローラ上
AlertController
を提示しているのでちょうど
self.dismissViewControllerAnimated(true, completion: nil)
を書く代わりに、それの
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
を呼び出していますさ
dismissviewcontrollerビューを呼び出す方法は? (親ビューまたはナビゲーション)は、一部のスクリーンショットまたはコードを共有します。 –
nishith Singhのソリューションは機能しましたか? –
いいえ動作しませんでした –