2010-02-20 8 views
1

안녕 ...iPhone - 인터페이스 방향이 바뀌 었습니까? 나는이 코드 조각이

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return YES; 
} 

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){ 
    // WTF, this runs when I change to Landscape 
    } else { 
    // this runs when I change to Portrait??? shouldn't it be the contrary? 
    } 
} 

당신이 보는대로

는 코드 내가를 변경할 때, 내 말은, 일부는 실행해야 반대로 실행 장치를 세로 방향으로 이동하면 코드의 가로 부분이 실행되고 그 반대의 경우도 마찬가지입니다.

언제 장치를 켜면 self.view가 회전합니다.

이 UIInterfaceOrientationIsPortrait 인터페이스가 회전하기 전의 테스트 방법 또는 누락 된 부분을 테스트하는 방법은 무엇입니까?

도움을 주셔서 감사합니다.

답변

6

이 메서드의 이름은 didRotate InterfaceOrientation이므로 자연히 interfaceOrientation 매개 변수에는 새 방향이 아니라 이전 방향이 포함되어 있습니다.

+0

아 .... 분명히! 나는 이름에서 FROM을 결코 알아 차리지 않았다. .. 하하. 감사. – SpaceDog

관련 문제