菜鸟教程小白 发表于 2022-12-11 19:25:41

ios - 覆盖函数准备(用于 segue : UIStoryboardSegue, 发件人 : Any?)未被调用


                                            <p><p>我在我的项目中使用了 RevealViewController。我已经为 segueAction 正确地提供了所有连接。但是 segue 方法没有调用。我已经在objective-c中使用了它,它工作正常。但是为什么它没有 swift 调用。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您是说所有连接都在 Storyboard 中,并且没有调用委托(delegate)方法。</p>

<p>所以答案很简单,可以是以下两种选择之一:</p>

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

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

<p>3- 另一个我无法解释的选项(曾经发生在我身上),仅与 swift 相关! <strong>您的委托(delegate)方法是在 ViewController 中定义的,而不是作为扩展。</strong>我不知道为什么,但它在过去给我带来了问题。您(可能)需要将您的委托(delegate)方法定义为以下伪代码:</p>

<pre><code>// MARK: UICollectionViewDataSource implementation
extension YourCollectionViewController {
    func yourDataSourceDelegeteMethod() { ... }
}
</code></pre>

<p>为您的 Collection View 委托(delegate)实现做同样的事情</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 覆盖函数准备(用于 segue : UIStoryboardSegue, 发件人 : Any?)未被调用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/47741791/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/47741791/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 覆盖函数准备(用于 segue : UIStoryboardSegue, 发件人 : Any?)未被调用