在标签栏控制器内查看控制器不会在旋转时自动调整大小 [英] View controllers inside tab bar controller not auto-resizing on rotation

查看:71
本文介绍了在标签栏控制器内查看控制器不会在旋转时自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更正:视图控制器不会自动调整大小而不是自动旋转。)

(Correction: the view controllers are not auto-resizing instead of not auto-rotating.)

在iPad应用中,我在标签栏控制器中有五个常规视图控制器(不是导航控制器或类似的东西)。标签栏控制器只是在app委托中声明的普通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;

到tabbar控制器的子视图控制器的每个viewDidLoad方法。

To each viewDidLoad method of the sub-viewcontrollers of your tabbar controller.

这篇关于在标签栏控制器内查看控制器不会在旋转时自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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