Select no tabs in a UITabBar

后端 未结 7 1552
心在旅途
心在旅途 2020-12-06 19:23

I\'m trying to select no tabs at all in my application. At first the first tab is selected, but I\'d like to deselect it so no tabs at all would be selected.

Don\'t

7条回答
  •  遥遥无期
    2020-12-06 19:50

    From the documentation:

    This view controller is the one whose custom view is currently displayed by the tab bar interface. The specified view controller must be in the viewControllers array. Assigning a new view controller to this property changes the currently displayed view and also selects an appropriate tab in the tab bar. Changing the view controller also updates the selectedIndex property accordingly. The default value of this property is nil.

    So, I would assume you need to [rootController setSelectedViewController: nil];.

    Update:

    To clarify a bit,

    [self.tabBarController setSelectedViewController:nil];

    There is also documentation on preventing the selection of tabs that could be helpful.

提交回复
热议问题