FGallery在我的其他视图中覆盖了所有旋转方法

时间:2012-02-12 19:19:13

标签: ios rotation screen-rotation

所以我已将格兰特戴维斯先生'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;

但这会强制所有观看到特定方向。我的一些观点允许轮换,有些则不允许。所以我想我的问题是,如何改变这一行以允许在某些视图中旋转而不在其他视图中旋转?我今天早上画空了!!

这里的任何帮助或想法都将不胜感激!!

1 个答案:

答案 0 :(得分: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

希望这有助于其他需要它的人。