Reputation: 9875
This may sound a newbie question, however I'm new iOS dev.
I'm calling following in viewDidLoad
CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height;
CGFloat navigationBarHegith = self.navigationController.navigationBar.bounds.size.height;
The return values are 0 for both, why this is so ? Doesn't it mean that navigationBar and tabBar are already loaded into memory and initialized.
Upvotes: 0
Views: 234
Reputation: 4732
it works fine for me. make shure, that your tab bar and nav. bar are allready inited, when you aske there properties. Do it in - (void)viewWillAppear:(BOOL)animated method.
Upvotes: 0
Reputation: 4396
viewDidLoad
doesn't guarantee that user interface objects have been instantiated - they're zero because they probably don't exist. Try viewWillAppear
.
Upvotes: 2
Reputation: 46598
It is more likely that your view controller does not have tab bar controller and navigation controller.
Check the value of self.tabBarController and self.navigationController and if they are nil (zero), unlike java or C++, invoke method on nil will simply just return 0, which is what you got.
Upvotes: 1