菜鸟教程小白 发表于 2022-12-12 09:40:52

ios - XIB 错误中的 UIPageViewController


                                            <p><p>我有一个子类 ViewController ,在 Interface Builder 中,我希望 VCView 的 subview 成为 UIPageViewController 的 View 。我将 UIPageViewController 的数据源设置为文件的所有者,并将 View 属性设置为我的 VC 的 subview 。这个功能可以实现吗?或者我不能以这种方式使用 UIPageVC?大多数示例是针对 Storyboard的,而不是由 NavigationController 方式推送的旧 VC。我得到这个异常''。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>当我有一个 UIViewController 作为我的 Root View 时,我也遇到了同样的事情 - 我的 UIViewController 有一个属性定义为:</p>

<pre><code>@property (strong, nonatomic) IBOutlet UIPageViewController *pageViewController;
</code></pre>

<p>我的 IBoutlet 也连接到我的 xib 中的 UIPageViewController。</p>

<p>解决方案:移除 IBoutlet 并断开 UIPageViewController 与我的 xib 的连接</p>

<pre><code>@property (strong, nonatomic) UIPageViewController *pageViewController;
</code></pre>

<p>也许崩溃与“每个 View 应该只有一个 ViewController ”有关</p>

<p>另外,如果你这样做,在“viewdidload”中
    _pageViewController.view = _apageView;</p>

<p>_apageView 在你的 UIViewController 中的位置:</p>

<pre><code>@property (strong, nonatomic) IBOutlet UIView *apageView;
</code></pre>

<p>这也会导致同样的崩溃发生 - 因此您需要这样做:</p>

<pre><code>;
</code></pre>

<p>那么崩溃不应该发生。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - XIB 错误中的 UIPageViewController,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15462491/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15462491/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - XIB 错误中的 UIPageViewController