我正在开发我的第一个iOS应用程序。这是一个简单的选项卡栏导航应用程序,带有链接到照片库的自定义按钮。
该应用程序使用MWPhotoBrowser库来实现图库功能。
画廊工作得很好,除了它不会旋转到横向。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"ShouldAutoRotate CALLED! - The FIELD");
return YES;}
- (IBAction)showRenderings:(id)sender {
NSMutableArray *photos = [[NSMutableArray alloc] init];
MWPhoto *photo;
photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"field_rendering_1" ofType:@"jpg"]];
photo.caption = @"The Field Rendering 1";
[photos addObject:photo];
photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"field_rendering_2" ofType:@"jpg"]];
photo.caption = @"The Field Rendering 2";
[photos addObject:photo];
photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"field_rendering_3" ofType:@"jpg"]];
photo.caption = @"The Field Rendering 3";
[photos addObject:photo];
_photos = photos;
// Create MWPhotoBrowser
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
browser.wantsFullScreenLayout = YES;
[browser setInitialPageIndex:0];
[self.navigationController pushViewController:browser animated:YES];
}
我检查了我的视图控制器和MWPhotoBrowser中的所有- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
。他们都返回YES。
为什么MWPhotoBrowser不能旋转到横向?
发布于 2014-02-25 14:00:56
当您为多个方向使用导航控制器时,在这种情况下,您需要创建UINavigationController的子类,然后为该子类中支持的方向编写适当的代码,然后在应用程序中使用它。here一些示例代码,以便您可以查看。
发布于 2012-05-03 01:55:35
正如你问题中的评论所写的,我也有同样的问题。
我的问题是我使用的是Tabbar。Tabbar和旋转的秘诀在于,tabbar中的所有视图控制器都必须支持横向模式。通过在此方法中返回YES来完成此操作:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
参考:Why won't my UITableView rotate?
在那次修正之后,对我来说就像是魅力一样!
https://stackoverflow.com/questions/10390722
复制相似问题