2011-08-14 3 views
1

안녕하세요. 저는 방금 iPhone 프로그래밍을 시작했습니다. Xcode 3.2에서 iPad 및 iPhone 용 범용 앱을 만들었으며 evrerything이 정상적으로 작동합니다. 하지만 이제는 해당 앱에서 다음 기능을 구현하고 싶습니다.방법 : iPad에서 자동 회전 및 iPhone에서만 세로 모드를 사용 하시겠습니까?

iPad에서 자동 회전을 지원하고 iPhone에서만 세로로 표시되어야합니다.

나는 그 방법을 모릅니다.

은 내가 AppDelegate_iPad 위임 파일이, AppDelegate_iPhone 위임 파일, 및 공유 탭 아래의 ViewController와이 대표의 모두에 의해 공유됩니다.

아이디어가 있다면 어떻게 구현할 수 있습니까? 어떤 도움을 주시면 감사하겠습니다.

감사 비크이 회전 동작을 구현하려는 뷰 (들)에 대한 뷰 컨트롤러 (들)에서

답변

3

이처럼 shouldAutorotateToInterfaceOrientation 내부 검사를 수행합니다

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {  
    UIDevice* thisDevice = [UIDevice currentDevice]; 
    if (thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) 
    { 
     return true; 
    } 
    else 
    { 
     return interfaceOrientation == UIDeviceOrientationPortrait; 
    } 
} 
0

- (NSInteger)supportedInterfaceOrientations 

및/또는 AppDelegate에의 : 아이폰 OS 6 이상을 실행하는 앱도의 ViewController의를 구현하려는 것이다

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 

예를 들면,

- (NSInteger)supportedInterfaceOrientations 
{ 
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { 
     return UIInterfaceOrientationMaskAll; 
    } 
    return UIInterfaceOrientationMaskPortrait; 
} 
관련 문제