2016-09-26 3 views
0

저는 iPhone 전용 앱을 가지고 있는데 대부분이 Interface builder으로 제작되었습니다.iPad Storyboards가 추가되었습니다. "루트보기 컨트롤러가 필요합니다 ..."

각 스크린 크기/장치에 대한 스토리 보드가 있습니다. AppDelegate에서 올바른 스토리 보드를 선택하고로드합니다.

저는 이후로 내 애플 리케이션을 재 설계하고 이제는 iPad 호환성을 추가했습니다.

"iPad 전체 화면"및 "iPad Pro 전체 화면"에 크기를 고정시킨 두 개의 스토리 보드를 추가했습니다.

저는 기존 iPhone Storyboards에서 복사 한 후 첫 번째 보드에 "Initial View Controller인가"라고 틱했습니다. 나는 THIS POST을 따라 갔고 스토리 보드를 소스 코드로 열었고 대상을 기본에서 iPad로 업데이트했습니다.

Application windows are expected to have a root view controller at the end of application launch :

내가 아이 패드에서 응용 프로그램을 실행

은, 난 그냥 다음과 같은 오류와 함께 검은 화면을 얻을.

왜 이런 일이 발생합니까?

이 내가 올바른 스토리 보드 선택 내 AppDelegate에서 변경 한 유일한 일 :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

UIViewController *initialViewController = nil; 
CGSize result = [[UIScreen mainScreen] bounds].size; 

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ 

    if(result.height == 480){ 
     NSLog(@"iPhone 3.5 Inch"); 
     UIStoryboard *i4SB = [UIStoryboard storyboardWithName:@"iPhone35" bundle:nil]; 
     initialViewController = [i4SB instantiateInitialViewController]; 
    } 
    if(result.height == 568){ 
     NSLog(@"iPhone 4 Inch"); 
     UIStoryboard *i5SB = [UIStoryboard storyboardWithName:@"iPhone4" bundle:nil]; 
     initialViewController = [i5SB instantiateInitialViewController]; 
    } 
    if(result.height == 667){ 
     NSLog(@"iPhone 4.7 Inch"); 
     UIStoryboard *i47SB = [UIStoryboard storyboardWithName:@"iPhone47" bundle:nil]; 
     initialViewController = [i47SB instantiateInitialViewController]; 
    } 
    if(result.height == 736){ 
     NSLog(@"iPhone 5.5 Inch"); 
     UIStoryboard *i55SB = [UIStoryboard storyboardWithName:@"iPhone55" bundle:nil]; 
     initialViewController = [i55SB instantiateInitialViewController]; 
    } 

    //added iPad compatibility 
    if(result.height == 1024){ 
     NSLog(@"iPad Mini(2,3,4) or iPad Air(1,2) or iPad(3,4) or iPad Pro(9.7inch)"); 
     UIStoryboard *iPadMiniSB = [UIStoryboard storyboardWithName:@"iPadFull" bundle:nil]; 
     initialViewController = [iPadMiniSB instantiateInitialViewController]; 
    } 
    if(result.height == 1366){ 
     NSLog(@"iPad Pro(12.9 Inch)"); 
     UIStoryboard *iPadProSB = [UIStoryboard storyboardWithName:@"iPadPro" bundle:nil]; 
     initialViewController = [iPadProSB instantiateInitialViewController]; 
    } 
} 

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
self.window.rootViewController = initialViewController; 
[self.window makeKeyAndVisible]; 
return YES; 
} 
이 이

업데이트]/해결 방법 : 바랏 Nakum 아래에 언급 한 바와 같이

, 당신은 UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone을 제거 할 수 있습니다 조건.

물론 iPad에 대한 추가 조건을 추가 할 수도 있습니다 (이것이 내가 한 것입니다).

은 이제 다음과 같습니다 :이 또한 답변 here로 확인

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ 
    //set iPhone device storyboards here 
} 
else if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 
    //set iPad device storyboards here 
} 

.

+0

야, 신의 사랑을 위해, autolayout을 배웁니다! 각 화면 크기에 스토리 보드를 설치하는 것은 극히 나쁜 습관입니다. –

+0

자동 레이아웃이 싫습니다. 절대로 모든 장치에서 잘 어울리는 것 같지 않습니다. (또한,이 응용 프로그램의 목적을 위해, 그것은 정말로 상관 없습니다 어느 쪽이든). 의심의 여지가 있지만 앞으로 할 일입니다. – Reanimation

답변

2

이 상태를 제거하십시오.

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

장치가 아이폰의 경우에만 해당됩니다.

iPad 스토리 보드가 초기화되지 않습니다.

희망이 도움이됩니다.

관련 문제