【发布时间】:2013-04-04 15:44:57
【问题描述】:
我有UITableViewController,其中一个选项卡上是UINavigationViewController。 UINavigationController根视图控制器为UITableViewController,点击单元格时出现UIViewController,需要锁定在Landscape中。
我希望每个 Controller 都锁定在 Portrait,除了提到的必须锁定在 Portrait 的 UIViewController。
我尝试了以下方法:
CustomTabBarController.m:
#import "CustomTabBarController.h"
@implementation CustomTabBarController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return [self.selectedViewController supportedInterfaceOrientations];
}
@end
CustomNavigationController.h:
#import "CustomNavigationController.h"
@implementation CustomNavigationController
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate
{
return YES;
}
@end
在必须锁定到 Landscape 的 UIViewController 中,我放了:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotate
{
return YES;
}
但它不起作用,我可以将它旋转到横向,它会保持锁定在横向,但我希望它自动出现在横向中。
有什么建议吗?
【问题讨论】:
标签: iphone ios uiviewcontroller orientation landscape