我將方向設置爲RootViewController中左側的橫向,但是在viewDidLoad或viewWillAppear中,VC的視圖邊界不會旋轉。在viewDidAppear中,它有一個正確的框架。我認爲這不是一個好地方,我該怎麼做?我應該在ViewController中設置子視圖框架
@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
我試過了,沒有調用此方法.. – DJean