2013-02-01 214 views
0

我在尋找Apple用來全屏顯示大量圖像的類的名稱(類似於iPad上的AppStore-App,當您點擊任何應用程序的預覽圖像時。視圖的底部是一個帶有少量預覽圖像的酒吧,來自所有圖像)。全屏顯示多個圖像

如果這是一個公開課,它是如何調用的,它是否也適用於iPhone?

+2

不,你必須自己建造它。但它不應該那麼困難。 – dasdom

+0

我很害怕這個答案......我想知道爲什麼蘋果希望開發人員能夠建立自己的圖像全屏主持人,儘管它經常需要。不管怎麼說,還是要謝謝你! – pmk

+0

因爲他們很懶。 ;)對不起,這是一個真正的問題嗎?你有沒有在任何其他平臺上構建應用程序?在大多數平臺上,你必須自己構建幾乎所有的東西非常非常,你有很多可以用在iOS開發中的東西。 – dasdom

回答

0

好的,我創建了我自己的ImageFullScreenPresenter。 對於任何試圖建立自己的ImageFullScreenPresenter的人來說,重要的是讓它成爲UIViewController的一個子類。

PKImageFullScreenPresenter *pkImageFullScreen = [[[PKImageFullScreenPresenter alloc] initWithNibName:@"PKImageFullScreenPresenter" bundle:nil imageArray:myImageArray] autorelease]; 
     AppDelegate *appDel = (AppDelegate *)[UIApplication sharedApplication].delegate; 
     UIViewController  *rootViewController; 
     if (DEVICE_IS_IPAD) { 
      //since the splitviewcontroller is the rootviewcontroller on ipad i set it as my temporary rootViewcontroller for ipad 
      rootViewController = appDel.splitViewController; 
     } 
     if (DEVICE_IS_IPHONE) { 
      //on iphone i need the tabbarcontroller as temporary rootviewcontroller 
      rootViewController = appDel.tabBarController; 
     } 
     //set the alpha to zero, so it can fade in animated 
     pkImageFullScreen.view.alpha = 0; 
     //save the temporary rootViewController, so I can set it back when dissmissing the ImageViewController 
     pkImageFullScreen.superViewController  = rootViewController; 

     //hide the status bar 
     [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 

     //setting black backgroundcolor 
     [UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor blackColor]; 

     //init the fullscreencontroller as rootview 
     [[UIApplication sharedApplication].keyWindow setRootViewController:[[[UINavigationController alloc] initWithRootViewController:pkImageFullScreen] autorelease]]; 
//smooth fade animation 
     [UIView animateWithDuration:.5f 
         animations:^(void){ 
          pkImageFullScreen.view.alpha = 1; 
         }]; 

這樣做,讓我可以在iPhone和iPad上,您使用的是基於窗口的應用程序,在iPad上或任何一個splitViewController不管目前的ImageFullScreenPresenter。 當駁回ImageFullScreenPresenter我設置臨時保存RootViewController的背部與動畫:

- (void)closeView:(id)sender{ 
[UIView animateWithDuration:.5f 
        animations:^(void){ 
         self.view.alpha = 0; 
        }completion:^(BOOL finished){ 
         //show the statusbar again 
         [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade]; 
         //setting the statusbarstyle 
         [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; 
         //set the backgroundcolor for the window 
         [UIApplication sharedApplication].keyWindow.backgroundColor = GLOBAL_TINT_COLOR; //my custom color vor all GUI Objects 
         //set the temporary rootViewController back 
         [[UIApplication sharedApplication].keyWindow setRootViewController:superViewController]; 

         //sometimes the navigationbar hides the statusbar, the following two lines help me out 
         [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController setNavigationBarHidden:YES]; 
         [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController setNavigationBarHidden:NO]; 

        }]; 

} 

我不知道這是否是正確的道路要走,但它完美finefor我。我不必擔心任何旋轉問題,比如我直接將其添加到[UIApplication sharedApplication].keyWindow

我希望這可以幫助其他人嘗試做到這一點:)