UINavigationBar autoresizing

2019-01-17 05:00发布

In my app, I got a UINavigationController. Unfortunately, when I rotate the device and the interface orientation changes, the UINavigationBar doesn't change its height. In other iPhone applications, such as the Contacts.app, the navigation bar gets slightly less tall in landscape mode. It must be built-in, because if you take the navigation sample app from the XCode menu and add interface orientation to it, it does change the navigation bar's height properly.

How can I make the navigation bar resize like it does in all other iPhone apps I've seen?

8条回答
我命由我不由天
2楼-- · 2019-01-17 05:32
(void)viewWillLayoutSubviews {
      self.navigationItem.titleView.bounds = self.navigationController.navigationBar.bounds;
}
查看更多
该账号已被封号
3楼-- · 2019-01-17 05:35

I just tried a few things just within Interface Builder and Xcode and as long as you use the UINavigationBarController as RootViewController it works as described - getting smaller. Did you change any things within the Controller itself or in parts of how the Controller is loaded? Especially concerning the firing of events? I had some bad expiriences with the UITabBarController in terms of breaking the proper messaging and got some 'interessting' view side effects. Just a try and a guess.

查看更多
登录 后发表回答