2016-10-25 59 views

回答

0

添加和使用didRotateFromInterfaceOrientation方向委托方法。

布局子视图使用的UIViewautoresizingMask财产,

一样,

YourView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

UIView documentation

当一个视图边界的变化,这种观点将自动调整根据其 子视图到每个子视图的自动调整掩码。

autoresizingMask更改为None以外的值将触发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 
} 
相关问题