My app using a Tab Bar Controller using storyboards. During the first time through the app, I want to use a UIPoppver on each of the Tab Bar buttons. However, to do this, I need to know the CGRect for each (I think). How do I go about doing this?
Asked
Active
Viewed 110 times
0
-
possible duplicate of [Getting the frame of a particular tab bar item](http://stackoverflow.com/questions/6325457/getting-the-frame-of-a-particular-tab-bar-item) – Toseef Khilji Feb 07 '14 at 14:24
-
Thanks, how do I reference my TabBarController, as it's hooked up using storyboards, and no code? – Paul S. Feb 07 '14 at 14:42
1 Answers
0
here is how I solved this, thanks to the link provided above:
In my AppDelegate.h
Added:
- (NSMutableArray *)tabBarMutableArray;
In my AppDelegate.m
Added:
- (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;
}
Now I can access the value anywhere with this:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Array AppDelegate: %@", [appDelegate tabBarMutableArray]);
Results:
"<_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>>"

Paul S.
- 1,342
- 4
- 22
- 43