Search code examples
xcodeuitabbarcontrolleruipageviewcontrollermwphotobrowser

Paging in MWPhotoBrowser not working properly after implementing custom tabbar


I'm using MWPhotoBrowser in a project and everything worked great until I implemented a custom tabbar (to make one of the tab items higher and wider). I used RXCustomTabBar as a starting point for my tabbar and only modified it a bit, no meaningful changes though.

After implementing the new tabbar and in the app open the MWPhotoBrowser I can only view the first photo. I can still scroll in the photobrowser but no other photos than the first is shown. Neither can I toggle the "fullScreenLayout" that is implemented in the MWPhotobrowser when I'm not viewing the first photo.

I'm simply confused since I have no idea what is causing this problem. I know it's a far fetched question since it's two custom made libraries I'm working with but perhaps someone has experienced a similar problem in the past. Would be very grateful for suggestions!

This is the code I use to push the MWPhotoBrowser:

MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
[self.navigationController pushViewController:browser animated:YES];

I tried presenting the browser modally with:

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

That way the photos are shown correctly but I have no navigation bar.


Solution

  • After hours of headache I came up with a solution:

    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    [browser setInitialPageIndex:indexPath.item];
    UINavigationController *navBar = [[UINavigationController alloc] initWithRootViewController:browser];
    [self.navigationController presentModalViewController:navBar animated:YES];
    

    I.e. I create a UINavigationController in which I embed my MWPhotoBrowser and then present the navigationcontroller modally.