UIView - 中心对齐UIView的所有内容?

Nit*_*h M 4 iphone xcode rotation alignment ipad

如何居中对齐视图的所有内容.当我旋转iPad的内容不对齐中心时,它自己如何解决这个问题?

谢谢!!!

Anu*_*rag 7

提供didRotateFromInterfaceOrientation方法的实现并集中所有子视图.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    for(UIView *subview in [self.view subviews]) {
        subview.center = self.view.center;
    }
}
Run Code Online (Sandbox Code Playgroud)