我有一个标签栏应用程序,其中我有 3 个不同的视图,每个视图都有自己的视图控制器。
在标签条码中,我有这个来处理旋转。
#import "RotatingTabBarController.h"
@implementation RotatingTabBarController
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
@end
然后在我想根据设备方向旋转的第二个视图控制器中:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
对于我不想旋转的其他两个视图,我设置了这个方法。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
问题:所以当你旋转设备时,这在视图 1 和视图 3 中工作正常,它们保持在所需的纵向模式。当我在视图 2 中旋转到横向时,视图会按预期进行并旋转到横向。但是,当在视图 2 中处于横向模式时单击视图 1 或视图 3 选项卡时,视图 1 和视图 3 处于横向模式。
即使视图 2 旋转为横向,我也不知道如何强制它们纵向显示。
有人知道怎么做吗?