在标签栏导航应用程序中使用时,MWPhotoBrowser不会旋转到横向

时间:2012-04-30 21:17:35

标签: iphone landscape

我正在开发我的第一个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];

}

我检查了View Controller和MWPhotoBrowser中的所有- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation。他们都返回YES。

为什么MWPhotoBrowser不会旋转到横向方向?

2 个答案:

答案 0 :(得分:2)

在这种情况下,当您使用导航控制器进行多个方向时,您需要创建UINavigationController的子类,然后在该子类中为方向支持制作适当的代码,然后在您的应用程序中使用它。 here一些示例代码,以便您查看..

答案 1 :(得分:1)

如同您的问题中的评论一样,我遇到了同样的问题。

我的问题是我使用的是Tabbar。 Tabbar和旋转的秘诀是tabbar中的所有viewcontrollers都必须支持横向模式。通过在此方法中返回YES来执行此操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

参考:Why won't my UITableView rotate?

在纠正之后,对我来说就像魅力一样!