2011-04-22 97 views
3

enter image description here与功能/按钮

“像标签”的iOS导航栏会是什么使这些按钮的最好方法?我没有右/左按钮的问题,但这个“标签”功能正在逃避我。

我想加入对viewDidLoad中自定义按钮一样的:

UIButton *profileBtn = [[UIButton alloc] initWithFrame:CGRectMake(50, 5, 100, 30)]; 
[profileBtn setTitle:@"Profile" forState:UIControlStateNormal]; 
[self.navigationController.navigationBar addSubview:profileBtn]; 

然而,然后按钮停留在导航栏上,直到我手动得到他们。当然有更好/更简单的方法来做这样的事情? (请注意,我已经在屏幕底部使用了UITabBarController)

回答

1

使用UISegmentedControl。通过在第一个位置添加并相应地隐藏/显示切换视图。如果这消耗了太多的内存,请及时创建它们,并从超级视图中删除不活动的内存。

Here is a tutorial关于UISegmentedControl。

+0

啊,谢谢!我的导航设置方式,让它工作起来有点痛苦,但我现在就开始了。 – Buchannon 2011-04-27 18:43:41