开发者

how to use buttons from HomeView to select tabs from uitabcontroller

My Apps main view is having 5 buttons and I'm having tabbarcontroll开发者_运维百科er with 5 tabs.So I need to select each tabs from each button action. Thanks in advance


Do something like this:

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


Use

self.tabBarController.selectedIndex = i; 

insted of i write the number of tab witch you wish !!!


assign tags to each button in view as 0,1,2,3,4 and use the same action for all buttons as

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

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

    [self.tabBarController.view setNeedsDisplay]; 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜