2011-04-22 89 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