【发布时间】:2016-01-13 13:35:39
【问题描述】:
手头的问题如下:我展示了一个 UIAlertController。如果用户按下删除,视图应该返回到第一页,即class TableViewQuery: PFQueryTableViewController类。
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? -
@bevroy 这是一个推送(显示)
标签: ios swift uiviewcontroller segue