2011-08-05 4 views
1

IF 문을 사용하여 장치의 방향이 바뀌는시기를 감지하고, 방향이 변경되면 새로운보기가 표시되고 한 개의 세로 및 다른 가로가 표시됩니다. 유일한 문제는 세로에서 가로로 회전하고 가로보기에 표시되는 경우 완전히 회전하지 않은 것입니다. 그것은 여전히 ​​초상화에서, 90도 벗어나 있어야합니다. 당신의 도움을 주셔서 감사합니다!보기가 올바르게 회전하지 않습니다.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     //portrait 

     self.view = portrait; 


    } else { 
     //landscape 

     self.view = landscape; 

    } 

} 

답변

1

애플이 제공하는 샘플 코드는 here입니다.

+0

완벽한, 감사합니다! –

0

그런 다음 didRotateFromInterfaceOrientation에 나중에 새보기를 밀어 willRotateToInterfaceOrientation 동안 대상 방향을 저장하여 해결할 수 있습니다.

+0

그래, 어떻게 할 수 있니? self.view = UIInterfaceOrientationPortrait와 유사한 점 UIInterfaceOrientationPortraitUpsideDown 등? 당신의 도움을 주셔서 감사합니다! –

관련 문제