点击UIViewController
项,即可拨打UITabBarController
。当我尝试使用UIViewController
viewDidLoad
方法获取导航栏的高度时,如下所示:
self.navigationController.navigationBar.frame.origin.y
self.navigationController.navigationBar.frame.size.height
以上两行都返回零。我怎么能得到导航栏的高度?
答案 0 :(得分:0)
请确保您没有错过以下任何一行代码
MyViewController *myViewController = [[MyViewController alloc] init];
UINavigationController *myNavigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
self.window.rootViewController = myNavigationController;
答案 1 :(得分:0)
试试这个......
CGFloat navigationBarHeight = self.navigationController.navigationBar.bounds.size.height;
答案 2 :(得分:-1)