NYTPhotoViewer icon indicating copy to clipboard operation
NYTPhotoViewer copied to clipboard

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

Open bcapps opened this issue 9 years ago • 7 comments

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.

bcapps avatar Feb 27 '15 15:02 bcapps

Unfortunately, this issue still persists :(

agordeev avatar Jul 21 '16 14:07 agordeev

Has anyone found a fix for this bug?

wraithseeker avatar Aug 03 '16 17:08 wraithseeker

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 avatar Aug 05 '16 01:08 yunnnyunnn

@yunnnyunnn Thanks, your workaround works fine!

agordeev avatar Aug 05 '16 05:08 agordeev

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
    }
}

elsesiy avatar Jan 05 '17 05:01 elsesiy

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

BesatZardosht avatar Aug 16 '17 19:08 BesatZardosht

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

benguild avatar May 01 '18 06:05 benguild