导航栏的横向模式问题
我有一个 ViewController 来管理一个视图,其中有一个 Table View、一个 ImageView 和一个导航栏。 当我将其置于横向模式时,导航栏的大小不会调整为 32,它仍然保持为 44 我首先尝试在 IB 中使用自动调整大小但没有成功,然后我尝试将此代码放入 ViewController
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
//[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
CGRect frame = self.navigationController.navigationBar.frame;
if (UIInterfaceOrientationIsPortrait(orientation)) {
frame.size.height = 44;
} else {
frame.size.height = 32;
}
self.navigationController.navigationBar.frame = frame;
}
但什么也没有。 我该如何解决这个问题?
I have a ViewController that manages a view in which I have a Table View, an ImageView and a Navigation Bar.
When I put it in the landscape mode the Navigation Bar doesn't resize to 32, it still remains to 44
I tried first to use the autosizing in IB without success, then I tried to put this code in the ViewController
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
//[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
CGRect frame = self.navigationController.navigationBar.frame;
if (UIInterfaceOrientationIsPortrait(orientation)) {
frame.size.height = 44;
} else {
frame.size.height = 32;
}
self.navigationController.navigationBar.frame = frame;
}
but nothing.
How can I solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我犯了一个错误,没有navigationController,所以我将IB中的导航栏与代码中的outlet navBar链接起来,并且我已经使用
它现在可以工作了,我只有图像视图的问题
I made a mistake, there isn't a navigationController, so I linked the navigation bar in IB with the outlet navBar in the code and I've used
It works now, I've only a problem with the image view
我对导航顶部栏的自定义背景图像也有同样的问题。
我的横向图像的高度不正确,它是 44 像素高,而不是 32 像素(@2x 版本相同,它是 88 像素而不是 64)。裁剪图像后,横向顶部栏具有正确的高度。
I had the same problem with a customized background image for the navigation top bar.
My landscape image was not the correct height, it was 44px high instead of 32px (same for the @2x version, it was 88px instead of 64). After cropping the images, the landscape top bar has the correct height.