2010-06-14 2 views
1

이 코드를 사용하고 있지만 개인 API이며 사과도 거부합니다! 내가 다음은 세로 모드로 발표 할 예정이다 내 응용 프로그램을 열 풍경에 내 장치를 회전하면pushViewController를 사용할 때 UIViewController를 현재 방향으로 업데이트하는 방법은 무엇입니까?

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; 

, 내가 다음 업데이트됩니다 다른 방향으로 내 장치를 회전해야합니다.

UIViewController를 호출 할 때 올바른 방향으로 업데이트하는 방법은 무엇입니까?

답변

0

당신은 당신의 UIViewController 클래스에서 추적 코드를 사용한다 :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

을 유 런타임에 방향을 업데이트해야하는 경우 다음 U가있는 다른 일정

return (interfaceOrientation == UIInterfaceOrientationPortrait);

+0

감사 Yakov,이 코드를 반환 장치가 방향 변경이있을 때 전화 할 것입니다. 내 문제를 해결할 수 있습니다. 즉, 내 방향을 잘못 누르면 잘못된 방향이 표시됩니다. 그래서 내가 setOrientation으로 강제한다면 : 그것은 사과에 의해 거절 될 것입니다. – RAGOpoR

+0

그래서 ... 또한 '초기 인터페이스 방향'속성을 info.plist에 추가하려고합니다. 예 : '가로 (오른쪽 홈 버튼)'또는 '세로 (홈 상단 버튼)'값을 설정할 수 있습니다. – Yakov

관련 문제