所以我合并了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/