我的应用程序使用故事板控制器使用故事板。在第一次通过应用程序时,我想在每个Tab Bar按钮上使用UIPoppver。但是,要做到这一点,我需要知道每个CGRect(我认为)。我该怎么做呢?
答案 0 :(得分:0)
这是我如何解决这个问题,感谢上面提供的链接:
在我的AppDelegate.h中
添加了:
- (NSMutableArray *)tabBarMutableArray;
在我的AppDelegate.m
中添加了:
- (NSMutableArray *)tabBarMutableArray;
{
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
NSMutableArray *tabBarItemsMutableArray = [NSMutableArray new];
UITabBar *tabBar = tabController.tabBar;
for (UIView *view in tabBar.subviews)
{
[tabBarItemsMutableArray addObject:view.description];
}
return tabBarItemsMutableArray;
}
现在我可以使用它来访问任何值:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Array AppDelegate: %@", [appDelegate tabBarMutableArray]);
结果:
"<_UITabBarBackgroundView: 0x145e19f70; frame = (0 0; 1024 56); autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0x1700359c0>>",
"<UITabBarButton: 0x145e15950; frame = (254 1; 76 55); opaque = NO; layer = <CALayer: 0x17002a9a0>>",
"<UITabBarButton: 0x145e19dd0; frame = (364 1; 76 55); opaque = NO; layer = <CALayer: 0x1700345c0>>",
"<UITabBarButton: 0x145d0f8a0; frame = (474 1; 76 55); opaque = NO; layer = <CALayer: 0x17803cc60>>",
"<UITabBarButton: 0x145e1a360; frame = (584 1; 76 55); opaque = NO; layer = <CALayer: 0x1700348e0>>",
"<UITabBarButton: 0x145e1a940; frame = (694 1; 76 55); opaque = NO; layer = <CALayer: 0x170034c60>>",
"<UIImageView: 0x145e1a090; frame = (0 -0.5; 1024 0.5); autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0x1700369e0>>"