iphone - 向以编程方式创建的标签栏添加标题
<p><p>我是 iPhone 开发的新手...现在我正在尝试构建一个应用程序,我在其中以编程方式创建 <code>UITabbarController</code>,如下所示:</p>
<pre><code>UITabBarController *tabbar = [ init];
firstViewController*firstView = [ initWithNibName:@"firstViewController" bundle:nil];
UINavigationController *tabItemOne = [[ initWithRootViewController: firstView] autorelease];
secondViewController *secondView = [ initWithNibName:@"secondViewController" bundle:nil];
UINavigationController *tabItemTwo = [[ initWithRootViewController: settings] autorelease];
tabbar.viewControllers = ;
tabbar.view.frame = CGRectMake(0,0,320,460);
;
;
</code></pre>
<p>在此,我如何为 <code>tabbar</code> 和那些 Controller 添加标题。
我试过了:</p>
<pre><code>firstView.title = @"First View";
</code></pre>
<p>和</p>
<pre><code>tabItemOne.title = @"First View";
</code></pre>
<p>但这两个不起作用..我该怎么做?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>设置<strong>aViewController.title</strong> 设置<em>navigationItem</em> 和<em>tabBarItem</em> 的<em>title</em>。如果您希望 <em>navigationItem</em> 和 <em>tabBarItem</em> 具有不同的 <em>title</em>,请执行此操作,</p>
<pre><code>// First set the view controller's title
aViewController.title = @"First View Tab";
// Then set navigationItem's title
aViewController.navigationItem.title = @"First View";
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 向以编程方式创建的标签栏添加标题,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/6702755/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/6702755/
</a>
</p>
页:
[1]