简体   繁体   中英

Status bar animating while a new view controller is pushed onto the stack

I have two view controllers that are pushed by a navigation controller. When the first view controller is active, a timer is used to hide the status bar with animation (the timer calls a method that internally hides the status bar by calling [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade] ). When the user taps on the view, the second view controller is pushed onto the stack. The second view controller needs the status bar to be visible in order for the navigation bar to be properly displayed. What happens sometimes is that while the second view controller is being pushed, the status bar is still animating and I end up with a navigation bar that is outside of the screen (basically, the view of the second view controller doesn't show the navigation bar). I was wondering if there is a way to stop the status bar animation before pushing or if there is a standard way to solve this issue.

You could keep a reference to your timer:

myTimer *timer = [NSTimer scheduledTimer...];

then invalidate it when you want the status bar animation to not happen:

[myTimer invalidate];
myTimer = nil;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM