【发布时间】:2015-05-31 17:43:54
【问题描述】:
我有一个从名为DetailViewController 的UIViewController 到MainViewController 的展开segue,定义为(在MainViewController 内):
@IBAction func deleteItemUnwind(sender: UIStoryboardSegue)
{
let sourceViewController = sender.sourceViewController
}
在 DetailView 中,我有一个应该执行连接到名为 deleteItemUnwindSegue 的场景出口的 segue 按钮,在 DetailViewController 我有 prepareForSegue 更改一些变量的值。这工作正常。问题是,我在DetailViewController中有以下代码
override func shouldPerformSegueWithIdentifier(identifier: String!, sender: AnyObject!) -> Bool {
if (identifier == "deleteItemUnwindSegue") {
let deleteItemAlert: UIAlertController = UIAlertController(title: "Delete item", message: "Are you sure you want to delete this item?", preferredStyle: .ActionSheet)
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
return false
}
deleteItemAlert.addAction(cancelAction)
let deleteItemAction: UIAlertAction = UIAlertAction(title: "Yes", style: .Destructive) { action -> Void in
return true
}
deleteItemAlert.addAction(deleteChoreAction)
self.presentViewController(deleteItemAlert, animated: true) {
}
}
return true
}
虽然prepareForSegue 代码有效,但未触发 Unwind segue 本身 以关闭视图。有什么想法吗?
【问题讨论】:
标签: ios iphone swift uiviewcontroller uialertcontroller