ios - FGallery 覆盖了我其他 View 中的所有旋转方法

标签 ios rotation screen-rotation

所以我合并了Grant Davis先生的FGallery进入我的照片库应用程序。除了在我的其他 View 中覆盖我所有的旋转方法之外,它的效果很好,而且我一生都无法弄清楚如何阻止它。这是 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;

但这会迫使所有 View 都指向该特定方向。我的一些观点允许轮换,而另一些则不允许。所以我想我的问题是,如何更改这条线以允许在某些 View 中旋转而不是在其他 View 中旋转?我今天早上画了一个空白!!

如有任何帮助或想法,我们将不胜感激!

最佳答案

所以我要继续回答我自己的问题。

答案是删除覆盖旋转的代码:

@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

希望这可以帮助其他需要它的人。

关于ios - FGallery 覆盖了我其他 View 中的所有旋转方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9251848/

相关文章:

matlab - 如何在 MATLAB 中平滑旋转 3D 图?

java - 将图像旋转 90、180 或 270 度

html - 旋转和对齐 div

android - 在基于TabLayout的应用程序上实现屏幕旋转

ios - React Native 应用程序在 Debug模式下工作,但在 iOS 上不工作 Release模式

ios - Swift 合并音视频 Swift3

android - SimpleCursorAdapter 的 onRestoreInstanceState

android - 旋转设备后恢复更改的菜单状态

ios - UIViewController 内的 UITableViewController

ios - 我必须使用 __strong 关键字吗?