问题描述
(更正:视图控制器不会自动调整大小而不是自动旋转.)
(Correction: the view controllers are not auto-resizing instead of not auto-rotating.)
在一个 iPad 应用程序中,我在一个标签栏控制器中有五个常规视图控制器(不是导航控制器或类似的东西).标签栏控制器只是在应用程序委托中声明的普通 UITabBarController.
In an iPad app, I have five regular view controllers (not navigation controllers or anything like that) inside a tab bar controller. The tab bar controller is just a plain UITabBarController declared in the app delegate.
所有视图控制器在 shouldAutorotateToInterfaceOrientation 方法中返回 YES.
All the view controllers return YES in the shouldAutorotateToInterfaceOrientation method.
在模拟器和设备上,旋转时,标签栏和当前视图控制器旋转,但当前选择的视图控制器(称为 A)没有正确调整大小.它保持它的纵向宽度和高度(但它是旋转的).
On both the simulator and device, on rotation, the tab bar and the current view controller rotate but the currently selected view controller (call it A) does not resize properly. It keeps its portrait width and height (but it is rotated).
如果我切换到另一个视图控制器 B,然后又回到 A(不再次旋转设备),A 的大小会正确调整.
If I switch to another view controller B and then back to A (without rotating the device again), A appears correctly resized.
这发生在五个视图控制器中的任何一个上
This happens with any of the five view controllers
为什么当前选择的视图控制器在旋转时不立即调整大小,我该如何解决?
Why doesn't the currently selected view controller resize immediately on rotation and how do I fix it?
谢谢.
推荐答案
你应该添加:
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
到标签栏控制器的子视图控制器的每个 viewDidLoad 方法.
To each viewDidLoad method of the sub-viewcontrollers of your tabbar controller.
这篇关于选项卡栏控制器内的视图控制器不会在旋转时自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)