NYTPhotoViewer
NYTPhotoViewer copied to clipboard
Presenting From UINavigationController with Navigation Bar and Status Bar Shown Causes Navigation Bar to Animate Up
This is the default behavior when presenting view controllers that don't show the status bar, however we could account for it in the animator.
Unfortunately, this issue still persists :(
Has anyone found a fix for this bug?
Here's my workaround (in swift) @wraithseeker @andrew8712 :
First, subclass NYTPhotosViewController
like this:
class FixedPhotosViewController: NYTPhotosViewController {
var shouldHideStatusBar = false
override func prefersStatusBarHidden() -> Bool {
return shouldHideStatusBar
}
}
Then, initiate the controller like this:
let photosViewController = FixedPhotosViewController(photos: [photo])
self.presentViewController(photosViewController, animated: true) {
photosViewController.shouldHideStatusBar = true
photosViewController.setNeedsStatusBarAppearanceUpdate()
}
@yunnnyunnn Thanks, your workaround works fine!
Swift 3 workaround:
import NYTPhotoViewer
class TempfixPhotosViewController : NYTPhotosViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.isStatusBarHidden = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show statusbar after dismissal again
UIApplication.shared.isStatusBarHidden = false
}
override var prefersStatusBarHidden: Bool {
return true
}
}
Objective c:
My_NYPhotoViewController.h file:
#import <Foundation/Foundation.h>
#import <NYTPhotoViewer/NYTPhotosViewController.h>
@interface My_NYPhotoViewController: NYTPhotosViewController
@end
My_NYPhotoViewController.m file:
#import "My_NYPhotoViewController.h"
@implementation My_NYPhotoViewController
- (BOOL)prefersStatusBarHidden {
return NO;
}
@end
It seems like a better workaround is to disable the status bar hiding entirely, and then use this pull-request: https://github.com/NYTimes/NYTPhotoViewer/pull/221