菜鸟教程小白 发表于 2022-12-12 09:47:53

ios - 停止导航栏重叠内容


                                            <p><p>我在我的应用程序中使用了 UINavigationController,它工作得比较好。在我的 Collection View 中显示标题时,导航栏似乎已设置为堆栈中较高的位置,从而允许在其下方呈现内容。</p>

<p>有谁知道我如何在导航栏下方而不是下方呈现标题?</p>

<p>非常感谢任何帮助!</p>

<p><strong>编辑</strong></p>

<p>如果有帮助,我运行了以下命令:</p>

<pre><code>NSLog(@&#34;Navigation Bar Bounds %@&#34;, NSStringFromCGRect(self.navigationController.navigationBar.bounds));
NSLog(@&#34;Navigation Bar Frame %@&#34;, NSStringFromCGRect(self.navigationController.navigationBar.frame));
NSLog(@&#34;Collection View Bounds %@&#34;, NSStringFromCGRect(self.collectionView.bounds));
NSLog(@&#34;Collection View Frame %@&#34;, NSStringFromCGRect(self.collectionView.frame));
</code></pre>

<p>输出如下:</p>

<pre><code> Navigation Bar Bounds {{0, 0}, {320, 44}}
Navigation Bar Frame {{0, 20}, {320, 44}}
Collection View Bounds {{0, 0}, {320, 504}}
Collection View Frame {{0, -22}, {320, 504}}
</code></pre>

<p><strong>编辑结束</strong></p>

<p>我已经上传了以下图片来演示这个问题:</p>

<p> Storyboard内部:</p>

<p> <img src="/image/wYwZC.png" alt="Inside My Storyboard"/> </p>

<p>应用程序何时加载以及导航栏隐藏的内容:</p>

<p> <img src="/image/EigSC.png" alt="When the application opens"/>
<img src="/image/91z9P.png" alt="What the Navigation bar is hiding"/> </p>

<p>完整的 Storyboard,显示导航 Controller 和 Root ViewController 。 UICollectionView 是 HomeViewController.h 文件中的一个 IBOutlet。</p>

<p> <img src="/image/DV1DO.png" alt="The Full Storyboard"/> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我认为您需要将 ViewController 的“tob bar”更改为“Navigation Bar”,并将控件放在上面</p>

<p>检查这张图片</p>

<p> <img src="/image/TovI9.png" alt="enter image description here"/> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 停止导航栏重叠内容,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15561449/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15561449/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 停止导航栏重叠内容