Krešimir Prcela
Krešimir Prcela

Reputation: 4281

Navigation toolbar extends vertically after returned from full screen video

The first screenshot is taken before playing video in full screen.

before

The second is taken after the video is opened in full screen and closed.

enter image description here

Any idea why navigation toolbar has extend?

Note: The hamburger button is not the part of the navigation item. It is faked in overlay in parent that holds its child controller inside standard container.

Nothing special inside the source:

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    bbiListic = UIBarButtonItem(image: UIImage(identifier: .IcoHeaderListic), style: .Plain, target: self, action: #selector(UIViewController.showListic))
    bbiFavorite = UIBarButtonItem(image: UIImage(identifier: .IcoHeaderStarEmpty), style: .Plain, target: self, action: #selector(LiveDogadjajViewController.toggleFavorite(_:)))

    ... 
    let items = [bbiListic!,bbiFavorite!]

    navigationItem.rightBarButtonItems = items
}

func someRefresh() {
    var items = [UIBarButtonItem]()

    items.append(bbiListic!)
    ...
    navigationItem.rightBarButtonItems = items
}

Update:

This appears to be a problem only on the latest version of iOS, 9.3

Upvotes: 7

Views: 158

Answers (3)

Krešimir Prcela
Krešimir Prcela

Reputation: 4281

I contacted the Apple developer technical support about this issue. They have determined it is probably a bug in iOS 9.3.

Bug id: 26439832, iOS SDK

This is easy workaround for view controller on stack:

// ... add this to init method
let nc = NSNotificationCenter.defaultCenter()
nc.addObserver(self, selector: #selector(didExitFullscreen(_:)), name: MPMoviePlayerDidExitFullscreenNotification, object: nil)

func didExitFullscreen(notification: NSNotification)
{

     // hack, fix for 9.3. 
     if #available(iOS 9.3, *)
     {
         navigationController?.setNavigationBarHidden(true, animated: false)
         navigationController?.setNavigationBarHidden(false, animated: false)
     }
}

Upvotes: 1

Harris
Harris

Reputation: 310

Pre-requisite:

a) Uncheck "extends edges" by selecting your uiviewcontroller from main.storyboard

b) no constraints exist between your video player and container controller

Solution:

Check if any of your buttons on the nav bar are bottom constrained. Either remove that constraint or apply a fixed height constraint to your custom nav bar view so that it stays the same height.

Upvotes: 1

pkc
pkc

Reputation: 8504

From your screenshots, it look like that height of status bar gets doubled. Try this:-

Before playing your video, hide the status bar

UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .None)

After ending the video, show the status bar

UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: .None)

Upvotes: 2

Related Questions