Navigation Bar Under Status Bar After Video Playback in Landscape Mode

navigation bar under status bar after video playback in landscape mode

Swift 3

In the presenting view controller, override the prefersStatusBarHidden property to only hide the status bar if it's in landscape.

override var prefersStatusBarHidden: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape
}

Then add an observer for when the device is rotated.

override func viewDidLoad() {
super.viewDidLoad()

NotificationCenter.default.addObserver(self, selector: #selector(videoDidRotate), name: .UIDeviceOrientationDidChange, object: nil)
}

In the observer's method, call setNeedsStatusBarAppearanceUpdate:

func videoDidRotate() {
self.setNeedsStatusBarAppearanceUpdate()
}

That should do it.

Status bar left white rectangle after rotate in landscape mode

SORRY!
I find the reason.
This is a custom view, that used for coloring statusbar.

Example of adding this view.

let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame)
let statusBarColor = UIColor(r: 240, g: 243, b: 245)
statusBarView.backgroundColor = statusBarColor
view.addSubview(statusBarView)

Thank you everyone!

iOS Status Bar remains in landscape after full screen video

Ok, I figured it out.

I added a button to the view controller that I present as a modal view with my video and that button triggers the following:

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self dismissModalViewControllerAnimated:YES];

When the button is triggered, the status bar is forced to portrait and the app returns to normal state. I removed the action for the "Done" button when I'm in fullscreen.

Hope this helps someone

Status Bar Hides The Navigation Bar

try like this

// create a new class of type UIViewController

class BaseViewController : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.videoExitFullScreen()
}

func videoExitFullScreen (){
navBar.frame.origin = CGPoint(x: 0, y: 20)
}
}

// replace UIViewController to BaseViewController

class ViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
}

Navigation bar hidden, move remaining view under status bar

  1. Click drop-down arrow on Top, Select Current view option. - It will Start from Status bar
    Sample Image


Related Topics



Leave a reply



Submit