1

そこで、GrantDavis氏のFGalleryをフォトギャラリーのアプリに組み込みました。他のビューですべての回転方法をオーバーライドする以外はうまく機能し、一生の間、それを停止する方法を理解することはできません。ギャラリーを処理するFGalleryのFGalleryViewControllerからのスニペットを次に示します。

@implementation UINavigationController (FGallery)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

   if([self.visibleViewController isKindOfClass:[FGalleryViewController class]]) {
        return YES;
    }

    // we need to support at least one type of auto-rotation we'll get warnings.
    // so, we'll just support the basic portrait.
    return ( interfaceOrientation == UIInterfaceOrientationPortrait ) ? YES : NO;
}

行を変更してみました:

    return ( interfaceOrientation == UIInterfaceOrientationPortrait ) ? YES : NO;

しかし、それはすべてのビューをその特定の方向に強制します。私の見解の中には回転を許可するものと許可しないものがあります。だから私の質問は、この線を変更して、一部のビューでは回転できるようにし、他のビューでは回転できないようにするにはどうすればよいかということだと思います。今朝は空白を描いています!!

ここでのヘルプやアイデアをいただければ幸いです!!

4

1 に答える 1

2

だから私は先に進んで自分の質問に答えるつもりです。

答えは、ローテーションをオーバーライドするコードを削除することです。

@implementation UINavigationController (FGallery)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if([self.visibleViewController isKindOfClass:[FGalleryViewController class]]) 
    {
        return YES;
    }

    // we need to support at least one type of auto-rotation we'll get warnings.
    // so, we'll just support the basic portrait.
    return ( interfaceOrientation == UIInterfaceOrientationPortrait ) ? YES : NO;
}


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    // see if the current controller in the stack is a gallery
    if([self.visibleViewController isKindOfClass:[FGalleryViewController class]])
    {
        FGalleryViewController *galleryController = (FGalleryViewController*)self.visibleViewController;
        [galleryController resetImageViewZoomLevels];
    }
}

@end

そして、電話してください:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

以内に@implementation FGalleryViewController

うまくいけば、これはそれを必要とする他の誰かを助けるでしょう。

于 2012-02-13T04:03:13.230 に答える