Fixing status bar jumping issue in iOS 8.3

This Blog post will show you how to fix the issue of the status bar jumping when dismissing a modally presented view controller that hides status bar on a view controller that shows it. This issue may be fixed automatically in the next release but is present at time of writing this.

Please note that this might not be the best solution but i thought id share with you a simple solution that seems to work fine for me.

Here below are a few steps to tackle this problem.

1. Create a property that stores whether or not to show the status bar on the presented view controller. (Don't forget to initialise the boolean in objective-c

(Swift) 
var hidesStatusBar: Bool = true

(Objective-c)
@property (nonatomic) BOOL hidesStatusBar;

-(void)viewDidLoad {
    ....
    hidesStatusBar = true;
    .....
}

2. override view controller method prefers status bar hidden and return the hidesStatusBar boolean.

(Swift)
override func prefersStatusBarHidden() -> Bool {
        return hidesStatusBar
    }

(Objective-c)
-(BOOL)prefersStatusBarHidden {
    return self.hidesStatusBar;
}

3. The final step is before dismissing the view controller update the hides status bar boolean and call set needs appearance update

(Swift)
    hidesStatusBar = false
    setNeedsStatusBarAppearanceUpdate()
    dismissViewControllerAnimated(true, completion: nil)

(Objective-c)
    self.showStatusBar = true;
    [self setNeedsStatusBarAppearanceUpdate];
    [self dismissViewControllerAnimated:true completion:nil];

All done. The dismiss should now the status bar on the presented view controller before dismissing the view controller. SWEET