如何在iPhone应用程序中获取对UITabBar的引用

0 iphone user-interface uitabbarcontroller

UIActionSheet有一个showFromTabBar:方法

- (void)showFromTabBar:(UITabBar *)view
Run Code Online (Sandbox Code Playgroud)

但是如何获得对UITabBar的引用?

我正在使用

UITabBar *tabBar = [self.tabBarController.view.subviews objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

我也看到有人遍历tabBarController.view.subviews并寻找UITabBar实例.有一个更好的方法吗?

Raf*_*ega 19

您可以使用

UITabBar *tabBar = self.tabBarController.tabBar;
Run Code Online (Sandbox Code Playgroud)