2016-10-25 2 views

答えて

0

didRotateFromInterfaceOrientationオリエンテーションデリゲートメソッドを追加して使用します。レイアウトサブビューに

UIView documentationからUIViewautoresizingMask財産、

と同様に、

YourView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

を使用します。

ビューの境界の変更は、そのビューが自動的に応じてその サブビューのサイズを変更する場合各サブビューの自動サイズ変更マスクに追加します。 None以外にautoresizingMaskを変更

layoutSubviewsをトリガします。

したがって、didRotateFromInterfaceOrientationデリゲートメソッドを使用してサブビューをレイアウトするには、次のコードを使用できます。

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 

    [self.view layoutIfNeeded]; 
    [self.view setNeedsLayout]; 
    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

    //....Other code 
} 


-(void)layoutSubviews{ 

    //write your code to draw here 
} 
関連する問題