2010-12-21 5 views
4

보기의 모든 내용을 가운데 맞춤하는 방법. 내가 회전 할 때 iPad 콘텐츠가이 문제를 해결하는 방법 자체를 정렬하지 않습니다 ??UIView - UIView의 모든 내용을 가운데 맞춤?

감사합니다 !!!

+0

nib 파일을 사용합니까, 아니면 프로그래밍 방식으로 추가합니까? – shannoga

+0

이것을 위해 nib 파일을 사용하고 있습니다. 나는 거기에 알맞은 속성이 있다는 것을 압니다. 그러나 이것을 설정함으로써 나는 여전히 회전 후에 같은 문제에 직면 해 있습니다. –

답변

7

didRotateFromInterfaceOrientation 방법 및 센터의 모든 서브 뷰의 구현을 제공합니다 : 이 같이 시도 할 수 있습니다.

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

가로 및 세로 모드의 콘텐츠 프레임을 프로그래밍 방식으로 변경해야합니다.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
     // set contents' frame for landscape 
    } 

    else { 
     // set contents' frame for portrait 

    } 

    return YES; 
} 
관련 문제