nytimes / NYTPhotoViewer

A modern photo viewing experience for iOS.
http://open.blogs.nytimes.com/2015/03/27/a-new-view-for-nytimes-photos/
Other
2.86k stars 378 forks source link

Presenting From UINavigationController with Navigation Bar and Status Bar Shown Causes Navigation Bar to Animate Up #10

Open bcapps opened 9 years ago

bcapps commented 9 years ago

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.

agordeev commented 8 years ago

Unfortunately, this issue still persists :(

wraithseeker commented 8 years ago

Has anyone found a fix for this bug?

yunnnyunnn commented 8 years ago

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()
}
agordeev commented 8 years ago

@yunnnyunnn Thanks, your workaround works fine!

elsesiy commented 7 years ago

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
    }
}
BesatZardosht commented 7 years ago

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
benguild commented 6 years ago

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