Enable rotate for mwphotobrowser in portrait app

79 views Asked by At

I have a fixed portrait app using objective-c, and i have a button click for open MWPhotoBrowser for browsing images. Now It works well in portrait mode but I want to make the MWPhotoBrowser for both portrait and landscape mode for rotate the phone. How can I do that, here is my code:

- (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];

 } 
1

There are 1 answers

0
Sean Lintern On

You have 2 options, you can enable the app to be portrait + landscape and go through your VCs and add the 3 rotation methods, shouldAutorotate, preferredOrientation and presentationOrientation, OR, you on this specific VC you can register for NotificationCenter notifications for device orientation, and even though the phone orientation may be locked and / or the apps orientation locked you should get a notification of the rotation happening and apply your own animation transformation to make it appear landscape, this is how most camera apps seem to do it as far as I am aware, becuase you dont want a view port of the camera rotating.

    NotificationCenter.default.addObserver(self, selector: Selector, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)