EDIT:
(Sorry, in my first answer I did not look at how the tabBarMutableArray
is created.)
In your AppDelegate the tabBarItemsMutableArray
(which is the return value of your -tabBarMutableArray
method) is created like this:
for (UIView *view in tabBar.subviews) { [tabBarItemsMutableArray addObject:view.description]; }
Hence there are no UIView
objects contained in that array but NSString
objects (the descriptions of all the subviews). That is why the following line in your viewcontroller.m is incorrect and won't work as desired:
UIView *tabView = [[appDelegate tabBarMutableArray] objectAtIndex:1];
The right hand side of that line is a NSString
, the left hand side is a UIView
.
You can fix this problem adding the lines
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tabController = (UITabBarController *)appDelegate.window.rootViewController;
UITabBar *tabBar = tabController.tabBar;
UIView *tabView = [tabBar.subviews objectAtIndex:1];
CGRect frame = tabView.frame
to your -showHomeTabBarPopOver
method. (Though there are neater methods depending on what you want to do...)
If you need the frames for all tab bar items and not only this particular one "at index: 1" I suggest you create a property in your AppDelegate.h:
@property (strong, nonatomic) NSArray *tabBarViews;
and implement its getter method in your AppDelegate.m:
- (NSArray *)tabBarViews {
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabController.tabBar;
return tabBar.subviews;
}
Then you can access your tab bar views more easily from within your viewcontroller.m including their frames:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UIView *tabView0 = [appDelegate.tabBarViews objectAtIndex:0];
CGRect frame0 = tabView0.frame;
UIView *tabView1 = [appDelegate.tabBarViews objectAtIndex:1];
CGRect frame1 = tabView1.frame;
etc.