开发者

Get UIViewController associated with a UITabBarItem

开发者 https://www.devze.com 2023-01-05 09:40 出处:网络
I have a UITabB开发者_如何学PythonarController with a bunch of tabs. When a new tab is selected, I want to be able to access the UIViewController associated with that tab.

I have a UITabB开发者_如何学PythonarController with a bunch of tabs. When a new tab is selected, I want to be able to access the UIViewController associated with that tab.

The -(void)tabBar:(UITabBar*)tabBar didSelectItem:(UITabBarItem*)item method on UITabBarDelegate gives me access only to the UITabBarItem.

Any suggestions on how go from this to the UIViewController that's displaying the contents of the selected tab?


Why not use .selectedViewController of UITabBarController?

Also, the UITabBar's .delegate is controlled by the tab bar controller. If you change it, the controller will not function properly. Use UITabBarController's .delegate instead.

0

精彩评论

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