我将方向设置为 RootViewController 中左侧的横向,但在 viewDidLoad 或 viewWillAppear 中,VC 的视图边界不旋转。在 viewDidAppear 中,它有一个正确的框架。我觉得在 viewDidAppear 中不是一个好地方,我该怎么办?
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = self.view.bounds;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
CGRect frame = self.view.bounds;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGRect frame = self.view.bounds;
}
#pragma mark - Orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft;
}
//for iOS 6 or later
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
@end
日志显示:
viewDidLoad,x = 0.000000, y = 0.000000,w = 300.000000 h = 480.000000
viewWillAppear:,x = 0.000000, y = 0.000000,w = 300.000000 h = 480.000000
viewDidAppear:,x = 0.000000, y = 0.000000,w = 480.000000 h = 300.000000