手頭的問題如下:我展示了一個UIAlertController。如果用戶按下刪除鍵,則視圖應該返回到class TableViewQuery: PFQueryTableViewController
類的第一頁。從UIViewController回到第一個ViewController
import UIKit
class DetailViewController: UIViewController {
var currentObject : PFObject?
@IBAction func pressDelete(sender: AnyObject) {
let deleteUser = UIAlertController(title: "Are you sure?", message: "Are you sure you want to delete the current user?", preferredStyle: UIAlertControllerStyle.Alert)
deleteUser.addAction(UIAlertAction(title: "Yes", style: .Default, handler: { (action: UIAlertAction) -> Void in
// Unwrap current object
if let object = self.currentObject {
object["firstName"] = self.firstName.text
object["lastName"] = self.lastName.text
object.deleteEventually()
}
}))
deleteUser.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction) -> Void in
//Do nothing
}))
presentViewController(deleteUser, animated: true, completion: nil)
}
我已經試過self.dismissViewControllerAnimated(true, completion: nil)
,但只是關閉UIAlertController。
我也嘗試了unwind segue,但是當它按下按鈕時,它立即做到了,而不是顯示UIAlertController。
我也試過segueForUnwindingToViewController(<toViewController: UIViewController:UIViewController>, fromViewController: <#T##UIViewController#>, identifier: <#T##String?#>)
但是我的toViewController不是UIViewController,而是PFQueryTableViewController。
我還有什麼可以嘗試的任何想法?
'DetailViewController',它是模態呈現還是嵌入在'UINavigationController'中? – bevoy
@bevroy它是一個Push(顯示) – SoundShock