Tried gaming the new rotation methods, I need to know if the device is being rotated in order to defer and cancel an action that is not required in the event of rotation.
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
_rotating = YES;
[coordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {
_rotating = NO;
}];
}
Seems straight forward and should work based on my interpretation of the documentation but apparently no. It seems that _rotating is set to YES and never gets set back to NO. Consequently, it seems my completion block is never called.
I had the same problem. I dived into the docs. The block you specify in notifyWhenInteractionEndsUsingBlock
gets called when:
When a transition changes from interactive to non-interactive then handler is invoked.
However, rotation is not an interactive transition. Once it starts you cannot interact with it. That's why the handler is never called.
I ended up using animateAlongsideTransition:completion:
method. It works like a charm.
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
_rotating = YES;
[super viewWillTransitionToSize:size
withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:nil
completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
_rotating = NO;
}];
}
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