1

所以我将格兰特戴维斯先生的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 回答