2012-08-14 6 views
1

iPhone 및 iPad에서 모두 작동하는 UIPageViewController 기반 앱을 개발 중입니다. 아이폰에서는 컨트롤러의 척추 위치가 항상 UIPageViewControllerSpineLocationMin으로 설정되기 때문에 문제가 없습니다. 하지만 iPad에서는 장치 방향이 가로로 설정되어있을 때 척추 위치를 UIPageViewControllerSpineLocationMid로 설정해야합니다. iPad에서 UIPageViewController 검은 화면

나는 내가 세로 컨트롤러를로드 할 때 YouTubeVideo

당신이 볼 수 있듯이, 모든 것을 완벽하게 작동합니다 ... 내가 가로 방향으로 컨트롤러를로드하는 경우에만 다음 비디오가 상황을 설명하는 이상한 문제가 또한 내가 가로로로드 할 때 장치를 회전 한 후에.

정말 문제가 어디인지 알 수 없습니다. 컨트롤러를로드하는 데 사용하는 코드는 다음과 같습니다.

if (chapter.controllers) { 

     currentPage = [chapter bookPageForCharIndex:location]; 

     //Load the correct controller for the bookmark page 
     NSArray *array = nil; 
     if (currentPage >= 0 && currentPage < chapter.controllers.count) { 
      if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice]orientation]) && UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) { 
       [self setDoubleSided:YES]; 
       if (chapter.controllers.count > currentPage+1) { 
        array = [[NSArray alloc]initWithObjects:[chapter.controllers objectAtIndex:currentPage],[chapter.controllers objectAtIndex:currentPage+1],nil]; 
       } 
       else { 
        array = [[NSArray alloc]initWithObjects:[chapter.controllers objectAtIndex:currentPage],[[[LSBookPageViewController alloc]init]autorelease],nil]; 
       } 
      } 
      else { 
       array = [[NSArray alloc]initWithObjects:[chapter.controllers objectAtIndex:currentPage],nil]; 
      } 
     } 
     else { 
      return; 
     } 
     [self playSoundsOfChapter:chapter]; 

     if (isRestarting) { 
      [self setViewControllers:array 
          direction:UIPageViewControllerNavigationDirectionReverse 
          animated:YES 
          completion:nil]; 
      isRestarting = NO; 
     } 
     else { 
      [self setViewControllers:array 
          direction:UIPageViewControllerNavigationDirectionForward 
          animated:YES 
          completion:nil]; 
     } 
     [array release]; 
    } 

답변

0

오류가 첫 번째 else 절에 있다고 생각합니다. 장치 방향 및 장치를 확인한 후 중단 점을 설정하고 코드를 단계별로 실행해야합니다. 나는 당신의 array이 다시 비어있는 것 같아요.

+0

불행하게도 배열 이상한 – Lolloz89

+0

뭔가 배열 (2 개 요소) 가득 그 범위에서 .. 여기에 무슨 일이 일어나고 .. 정확히이 개 필요한 항목이 있습니다,하지만 난이 방법으로 확인하는 경우 : - (무효) viewDidAppear를 :(BOOL) animated { NSLog (@ "% d", [[self viewControllerers] count]); } 나는 0 ... – Lolloz89

+0

당신은 올바른 길을 가고 있습니다 ...--) – Mundi