Is interactive viewing of the dismissal and status change controller BarStyle incompatible?

I present a modal UINavigationController with interactive firing. The parent view controller has a dark status bar, and the modal view controller has a status indicator. I am using the status bar display configuration based on the iOS 7 controller.

Everything works fine as long as I submit and dismiss the view controller non-interactively. However, when I start the interactive transition with the cancellation and cancels it, the color of the status bar remains dark.

I created a sample project . Press the "Menu" button, then start the interactive transition by panning from the right edge of the screen.

Things I tried:

  • calling -setNeedsStatusBarAppearanceUpdate on any of the navigation and view controllers that were involved after the transition was canceled.
  • Change navigationBar.barStyle to UIBarStyleDefault and back to UIBarStyleBlack

I also confirmed that the statusBarStyle of my modal navigation controller is configured correctly:

 (lldb) p (UIStatusBarStyle) [[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentedViewController] preferredStatusBarStyle] (UIStatusBarStyle) $8 = UIStatusBarStyleLightContent 

However, the status bar is black.

Any further idea what I could try?

+6
source share
2 answers

For me, this looks like an error ( rdar: // 15902745 ) in the UINavigationController . After the dismissal is canceled, the UINavigationController does not request its presentedViewController again for the preferredStatusBarStyle , but uses the preferredStatusBarStyle on its own. I worked on this by overwriting -childViewControllerForStatusBarStyle :

 - (UIViewController*)childViewControllerForStatusBarStyle { if (self.presentedViewController) { return self.presentedViewController.childViewControllerForStatusBarStyle; } return [super childViewControllerForStatusBarStyle]; } 

Then, to revive the change during (and not after) the dismissal, I also rewrote -preferredStatusBarStyle .

I applied a workaround to the sample project .

+6
source

Do not forget to call

 [self.transitionContext cancelInteractiveTransition]; 

in the implementation of the subclass UIPercentDrivenInteractiveTransition - (void)cancelInteractiveTransition . For inspiration, this is my implementation.

 - (void)cancelInteractiveTransition { id<UIViewControllerContextTransitioning> transitionContext = self.transitionContext; [transitionContext cancelInteractiveTransition]; UIView *fromView = [UIViewController fromViewForTransitioningContext:transitionContext]; UIView *toView = [UIViewController toViewForTransitioningContext:transitionContext]; if (self.presenting) { CGRect endFrame = CGRectOffset([[transitionContext containerView] bounds], 0, CGRectGetHeight([[transitionContext containerView] bounds])); [UIView animateWithDuration:ANIMATION_DURATION_PAN animations:^{ toView.frame = endFrame; } completion:^(BOOL finished) { [transitionContext completeTransition:NO]; }]; } else { CGRect endFrame = [[transitionContext containerView] bounds]; [UIView animateWithDuration:ANIMATION_DURATION_PAN animations:^{ fromView.frame = endFrame; } completion:^(BOOL finished) { [transitionContext completeTransition:NO]; }]; } 

}

edit: this seems to help in iOS 8.4. Tested in 7.1, but in no way. Apple may have fixed it recently.

0
source

All Articles