so i'm using the "Utility Application" template in Xcode and have the Main View Controller, where the user can hide and show the status bar using a button. I've also got the Flipside View Controller, using a modal segue, which has a done button to return to the Main VC. I've set it up so that whenever viewing the Flipside VC, the status bar is always NOT hidden. This means that if the user hides the status bar on the Main VC and transitions to the Flipside VC, it will animate on and if the user didn't hide the status bar and they transition, nothing happens to the status bar.
That's all good, the problem is transitioning back from the Flipside VC to Main VC. I need a condition to check the hidden state of the status bar in the Main VC, which would be called in the Flipside VC when pressing the done button.
I've looked into using a BOOL as well as NSNotificationCenter to send a message to the Flipside VC about the state of the status bar.
I had this code:
-(BOOL)checkStatusBarHidden:(id)input
{
BOOL result;
if ([UIApplication sharedApplication].statusBarHidden = YES)
{
result = YES;
}
else
{
result = NO;
}
return result;
}
But this is all just guessing and thinking I might be able to use it somewhere to inform the Flipside VC of the status bar state. I thought of maybe changing the
[UIApplication sharedApplication].statusBarHidden = YES)
to something like
self.statusBarHidden = YES //which of course isn't going to work
But anyway, as I said it's guessing and i'm not sure what to do.
You may think of storing the information about the status bar state in the MainViewController
using a property, e.g.
MainViewController.h
@property (nonatomic, assign) BOOL statusBarHidden;
then you can access that value from the FlipsideViewController
using the presentingViewController
property.
FlipsideViewController.h
MainViewController * mainVC = self.presentingViewController;
if (mainVC.statusBarHidden) {
// Do stuff
}
As a final remark, please change your checkStatusBarHidden:
method to something like
- (BOOL)checkStatusBarHidden {
return [UIApplication sharedApplication].statusBarHidden;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With