2013-02-11 2 views
-3

우선 Objective C의 새로운 기능이 있습니다. 첫 번째 앱을 개발하려고했는데 2 가지 스토리 보드를 사용하고 싶습니다. 하나는 iPhone 4/4S 용이고 다른 하나는 iPhone 5 화면 크기 용입니다. lionserdar에서 멋진 코드를 발견했습니다. How to switch to different Storyboard for iPhone 5?"선언되지 않은 식별자 사용"- 목표 C

내 문제는 내 AppDelegate.m에 코드를 추가 할 때입니다.

"선언되지 않은 식별자의 사용"InitializeStoryBoardBasedOnScreenSize "

그리고 나는 그것을 해결하는 방법을 모르겠어요. 감사합니다 이미.

-(void)initializeStoryBoardBasedOnScreenSize { 
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { // The iOS device = iPhone or iPod Touch 

     CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; 

     if (iOSDeviceScreenSize.height == 480) 
     { // iPhone 3GS, 4, and 4S and iPod Touch 3rd and 4th generation: 3.5 inch screen (diagonally measured) 

      // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35 
      UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone35" bundle:nil]; 

      // Instantiate the initial view controller object from the storyboard 
      UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController]; 

      // Instantiate a UIWindow object and initialize it with the screen size of the iOS device 
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

      // Set the initial view controller to be the root view controller of the window object 
      self.window.rootViewController = initialViewController; 

      // Set the window object to be the key window and show it 
      [self.window makeKeyAndVisible]; 
     } 

     if (iOSDeviceScreenSize.height == 568) 
     { // iPhone 5 and iPod Touch 5th generation: 4 inch screen (diagonally measured) 

      // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4 
      UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone4" bundle:nil]; 

      // Instantiate the initial view controller object from the storyboard 
      UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController]; 

      // Instantiate a UIWindow object and initialize it with the screen size of the iOS device 
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

      // Set the initial view controller to be the root view controller of the window object 
      self.window.rootViewController = initialViewController; 

      // Set the window object to be the key window and show it 
      [self.window makeKeyAndVisible]; 
     } 

    } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) 

    { // The iOS device = iPad 

     UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
     UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
     splitViewController.delegate = (id)navigationController.topViewController; 

    } 
} 
+0

메모장에 코드를 작성 하시겠습니까? XCode는 자동 완성 (인텔리 센스) 기능을 가지고 있으므로 수동으로 작성하지 마십시오! –

+1

코드를 표시하십시오. 이 메서드를 호출하려고합니까? AppDelegate.m 또는 다른 파일에서 호출하고 있습니까? 다른 파일의 경우 .h 파일에 선언을 추가 했습니까? – rmaddy

+1

아마도이 오류로 인해 어떤 행에 플래그가 지정되었는지 알려 주실 수 있습니다. –

답변

2

자본"나는 "InitializeStoryBoardBasedOnScreenSize에서 initializeStoryBoardBasedOnScreenSize을 다른?

+0

Nope. 둘 다 노력했다. 여전히 동일한 문제가 발생했습니다. – user2062381