ios - override func prepare(for segue : UIStoryboardSegue, sender : Any?) 未被调用

标签 ios swift prepared-statement

我在我的项目中使用了 RevealViewController。我已经正确地为 segue Action 提供了所有连接。但是 segue 方法没有调用。我已经在 objective-c 中使用了它,它工作正常。但为什么它不 swift 调用。

最佳答案

您是说所有连接都在 Storyboard 中并且未调用委托(delegate)方法。

所以答案很简单,可以是以下两个选项之一:

1- Collection View 的大小为零。在这种情况下,出于优化原因不会调用委托(delegate)方法

2- Collection View 的委托(delegate)和/或数据源属性未附加到 Storyboard 中的 View Controller 。您可以在连接 Pane 中检查这一点

3- 另一个我无法解释的选项(发生在我身上一次),只与 swift 有关! 您的委托(delegate)方法是在 View Controller 中定义的,而不是作为扩展定义的。我不知道为什么,但它在过去给我带来了问题。您(也许)需要将委托(delegate)方法定义为以下伪代码:

// MARK: UICollectionViewDataSource implementation 
extension YourCollectionViewController {
    func yourDataSourceDelegeteMethod() { ... }
}

为您的 Collection View 委托(delegate)实现做同样的事情

关于ios - override func prepare(for segue : UIStoryboardSegue, sender : Any?) 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47741791/

相关文章:

ios - WKWebView localHTMLString 似乎不适用于 iOS 8.4

ios - 如何使用 RestKit 映射 XML textContent?

swift - 我如何在 Swift 中使用这个 fetchRequest()?

PHP fetch_assoc 循环

PHP - 将 PDO 与 IN 子句数组一起使用

ios - iOS 上的 Crouton 等价物?

ios - 设置tableview的动态高度

ios - Alamofire 多个请求

swift - 清零弱变量和取消初始化,哪个先发生?

php - bind_result 成数组 PHP mysqli 预处理语句