This is a problem, e.g. when using the new multitasking feature on the iPad Pro. The proper fix seems to me:
- (void)handleGesture:(UIGestureRecognizer *)recognizer {
- [self setBackgroundVisibility:!(recognizer.state == UIGestureRecognizerStateEnded)];
+ [self setBackgroundVisibility:!(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled)];