Programmatically pressing a UITabBar button in Xcode

前端 未结 6 1269
无人及你
无人及你 2020-12-17 17:34

Sorry for the newbie question. I have a UITabBar in my main window view as well as an array of UINavigationControllers for each Tab. The structure is similar to the iPod a

6条回答
  •  清酒与你
    2020-12-17 18:04

    [myTabBarController setSelectedIndex:index]
    

    EDIT: Answering the part 2 question from the comment:

    You can define a method in AppDelegate for switching to a different tab.

    And you can get hold of appdelegate from anywhere and send a message.. something like:

     MyAppDelegate *appDelegate = (MyAppDelegate*) [[UIApplication sharedApplication] delegate];
     [appDelegate SwitchToTab:index]
    

提交回复
热议问题