gpt4 book ai didi

ios - 中途向后滑动时的奇怪行为

转载 作者:行者123 更新时间:2023-11-30 12:58:33 27 4
gpt4 key购买 nike

我遇到了一个奇怪的故障,我可以在顶 View Controller 被关闭之前使用以前的 View Controller 。

在我的主视图 Controller 中,我有一个带有委托(delegate)函数 didSelectRowAtIndexPath 的 TableView 。其功能如下:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("commentsSegue", sender: self)
}

这很好用,但是如果我已经显示了这个屏幕,如果我向后滑动一半,我可以再次选择它。这有点难以解释,但您可以使用一根手指向后滑动,另一根手指在主视图 Controller 上选择一个单元格。这将创建另一个新的“commentsSegue”的segue。我可以根据需要多次执行此操作,并且会执行多次操作。

我尝试通过使用来克服这个问题

if (self.presentingViewController?.presentedViewController == self) {

还有

if (self.navigationController?.topViewController.title == self.title) {

但这两个函数都返回主视图 Controller 作为事件 View Controller ,而不是“commentsSegue” Controller 。

如何阻止这种行为发生?

最佳答案

滑动时创建一个通知,检查您的目标 Controller .isKindOfClass是否是您当前的 Controller 。如果没有,请继续。

关于ios - 中途向后滑动时的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40126295/

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