旋转至横向时,iPhone视图控制器视图向下移动20像素 [英] iPhone view controller view shifted down 20 pixels when rotating to landscape

查看:111
本文介绍了旋转至横向时,iPhone视图控制器视图向下移动20像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UIViewController和UITabBar实现自定义的tabbarcontroller.到目前为止,一切工作正常,除非我将设备旋转到横向,否则UIViewController会将整个视图下移20像素,从而在状态栏和视图之间创建一个黑条.即使将视图旋转回纵向,该视图仍会向下移动20像素.

I am trying to implement a custom tabbarcontroller using a UIViewController and a UITabBar. Everything is working fine so far, except when I rotate the device to landscape, the UIViewController shifts the entire view down 20pixels, creating a black bar between the status bar and the view. Even when the view is rotated back to portrait orientation, the view is still shifted down 20pixels.

我需要怎么做才能去除黑条?我是否必须执行自定义轮换?如果是这样,我应该在哪里插入这些旋转?

What do I need to do to remove the black bar? Do I have to perform custom rotations? If so, where should I insert these rotations?

旋转前:

旋转后:

推荐答案

我也遇到过同样的问题.

I've experienced this same issue.

此讨论很有帮助: iPad尺寸的UIWebView

Tony 的答案帮助我发现,在创建子视图时,设置类似于以下内容的代码会很有帮助:

Tony's answer helped me discover that when you create a subview it's helpful to setup code similar to this:

UIWebView *webView = [[UIWebView alloc] init];
webView.frame = self.view.bounds;

如果您发布一些代码,我也许可以提供更具体的建议.

If you post some of your code I may be able to provide more specific advice.

这篇关于旋转至横向时,iPhone视图控制器视图向下移动20像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆