2011-04-29 24 views

回答

1

使用

self.tabBarController.selectedIndex = i; 

insted的的我給你寫希望標籤女巫的數量!

+0

helo ...我很抱歉它不工作,因爲self.tabbarController.selectedindex = 1意味着它在相同的viewcontroller,但我需要帶tabbar視圖 – Ramz 2011-04-29 11:00:51

+0

你能解釋你想要做什麼? – 2011-04-29 11:03:25

+0

我需要做一個帶有5個選項卡的TabBar控制器......並且相同的選項卡由一個包含5個按鈕的窗口驅動....因此,主視圖是5個按鈕,當它選擇時它將會選中相應的選項卡 – Ramz 2011-04-29 11:12:49

2

做這樣的事情:

- (IBAction)selectSecondTab:(id)sender { 
    self.tabBarController.selectedIndex = 1; 
    [self.tabBarController.view setNeedsDisplay]; 
} 
0

變量分配給每個按鈕在視圖0,1,2,3,4和使用所有按鈕同樣的動作爲

- (IBAction)selectTab:(id)sender 
{ 
    UIButton *button = (UIButton*)sender; 

    [self.tabBarController setSelectedIndex:[button tag]]; 

    [self.tabBarController.view setNeedsDisplay]; 
} 
相關問題