gpt4 book ai didi

ios - 在 shouldPerformSegueWithIdentifier UIAlertController 之后未执行 Unwind Segue

转载 作者:行者123 更新时间:2023-11-28 09:06:58 26 4
gpt4 key购买 nike

我有一个从名为 DetailViewControllerUIViewControllerMainViewController 的展开转场,定义为(在 MainViewController 中):

@IBAction func deleteItemUnwind(sender: UIStoryboardSegue)
{
let sourceViewController = sender.sourceViewController
}

在 DetailView 中,我有一个应该执行 segue 的按钮,该按钮连接到名称为 deleteItemUnwindSegue 的场景导出,在 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 本身 以关闭 View 。有什么想法吗?

最佳答案

我发现(在阅读 UIAlertController 之后)显示警报后的那一刻,执行后的代码,所以每次都会自动给出 false。我能够通过创建一个通用的 First Responder 来绕过这个问题,以 Exit 展开 segue,并让按钮项触发 segue。

关于ios - 在 shouldPerformSegueWithIdentifier UIAlertController 之后未执行 Unwind Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30560580/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com