手头的问题如下:我展示了一个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