0

我有一个使用objective-c 的固定肖像应用程序,我有一个按钮单击以打开MWPhotoBrowser 以浏览图像。现在它在纵向模式下运行良好,但我想为纵向和横向模式制作 MWPhotoBrowser 以旋转手机。我该怎么做,这是我的代码:

- (void) prepareForPhotoAlbum:(NSArray*)photoObjs {
self.photoURLArrays = [[NSMutableArray alloc]init];
for(int i=0 ; i<photoObjs.count ; i++){
    NSDictionary* dictOfImageObj = photoObjs[i];
    [self.photoURLArrays addObject:[MWPhoto photoWithURL: [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",ServerTopicImageURL,dictOfImageObj[@"filename"]]]]];
}
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
// Set options
browser.displayActionButton = YES;
browser.displayNavArrows = NO;
browser.zoomPhotosToFill = YES;
[browser setCurrentPhotoIndex:0];
browser.wantsFullScreenLayout = YES;

[self.navigationController pushViewController:browser animated:YES];

[browser showPreviousPhotoAnimated:YES];
[browser showNextPhotoAnimated:YES];

 } 
4

1 回答 1

0

您有 2 个选项,您可以将应用设置为纵向 + 横向并通过您的 VC 并添加 3 种旋转方法,shouldAutorotate、preferredOrientation 和 presentationOrientation,或者,您可以在此特定 VC 上注册 NotificationCenter 通知以获取设备方向,即使手机方向可能被锁定和/或应用程序方向被锁定,您也应该收到旋转发生的通知并应用您自己的动画转换以使其显示为横向,这就是大多数相机应用程序似乎这样做的方式我知道,因为您不希望相机的视口旋转。

    NotificationCenter.default.addObserver(self, selector: Selector, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
于 2016-12-19T10:27:42.957 回答