2012-11-30 55 views
1

我將方向設置爲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 

回答

1

您可以設定方向變化後的幀:

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
+0

我試過了,沒有調用此方法.. – DJean

0

我想應該是在這個函數

  • (vo ID)viewDidLayoutSubviews {}

蘋果的醫生說enter image description here

+0

你能離開 「不好」 有何評論? –

相關問題