0

Appleがフルスクリーンで多数の画像を表示するために使用するクラスの名前を探しています(AppStore-任意のアプリのプレビュー画像をタップしたときのiPadのアプリに似ています。ビューの下部にあるバーがありますすべての画像からの小さなプレビュー画像)。

これがパブリッククラスの場合、どのように呼ばれ、iPhoneでも利用できますか?

4

1 に答える 1

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;
                         }];

そうすることでImageFullScreenPresenter、ウィンドウベースのアプリやiPadのsplitViewControllerなどを使用している場合でも、iPhoneとiPadでプレゼンテーションを行うことができます。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];

                     }];

}

これが正しい方法かどうかはわかりませんが、私にとっては完全にうまく機能します。これをに直接追加した場合のように、回転の問題を心配する必要はありません[UIApplication sharedApplication].keyWindow

私はこれが同じことを達成しようとする他の人に役立つことを願っています:)

于 2013-02-20T09:49:48.093 に答える