2012-08-14 76 views
1

我正在開發基於UIPageViewController的應用程序,它可以在iPhone和iPad上使用。對於iPhone來說,沒有問題,因爲控制器的脊椎位置始終設置爲UIPageViewControllerSpineLocationMin。然而,在iPad中,當設備方向設置爲橫向時,我需要將主幹位置設置爲UIPageViewControllerSpineLocationMid。UIPageViewController在iPad上加載橫屏時的黑屏

我有一個奇怪的問題,只有當我橫向裝入控制器,下面的視頻會說明情況.. 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

不幸的是陣中擁有完全相同的2級需要的物品.. – Lolloz89 2012-08-14 12:24:31

+0

奇怪的事情發生在這裏。在該範圍的數組已滿(2元),但如果我檢查是這樣的: - (空)viewDidAppear :(BOOL)動畫NSLog(@「%d」,[[self viewControllers] count]); } } 我得到一個0 ... – Lolloz89 2012-08-14 13:23:33

+0

你在正確的軌道上; ;-) – Mundi 2012-08-14 14:34:51