菜鸟教程小白 发表于 2022-12-11 20:19:38

iphone - 如何访问和修改 UINavigationBar


                                            <p><p>我通过库将 UINavigationBar 添加到 View 。但我不知道如何从我的 ViewController.m 更改此 UINavigationBar。我的 View 还包括 TableView。此 View 必须从默认应用程序 View 中调用。</p>

<p>在 viewController.m 中,我添加了以下代码,但无法更改 NavigationBar 属性。</p>

<p>self.navigationItem.title=@"列表";
self.navigationItem.backBarButtonItem.title=@"Back";</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我认为这是不同的 UINavigationBar 和 UINavigationItem..
在 .h 文件中使用:</p>

<pre><code>UINavigationItem *item;
</code></pre>

<p>在.m文件中:</p>

<pre><code>item.title = @&#34;List&#34;;
</code></pre>

<p>不要忘记将 UINavigationItem 与 XIB 文件中的“项目”连接起来
双击 UINavigationBar 你会得到 UINavigationItem...
祝你好运</p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 如何访问和修改 UINavigationBar,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7670098/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7670098/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 如何访问和修改 UINavigationBar