简体   繁体   中英

iOS Control Center touches pass through to my Scroll View?

I have a UIScrollView that scrolls horizontally along the bottom edge of my application. I've noticed a bug where if the user swipes up to open Control Center, Control Center attaches to their finger, but my scrollViewDidBeginDragging method is called. Trouble is, no subsequent ending method is called, meaning my scroll view thinks someone started pulling it and never stopped.

Is this a known thing, that while opening Control Center (or I guess the notification center too) touches are passed through to the app beneath? It only appears to happen on a device, not in the Simulator (in the sim, the scrollViewDidBeginDragging delegate method is never called).

Anyone run into this? It seems rather difficult to guard against.

I experienced this bug with iOS 8. Both scroll views and other views with custom gestures were getting touches passed in when performing the swipe from the bottom gesture to reveal Control Center. I had some UIButtons near the bottom of the screen that would also begin tracking. None of these issues were happening with iOS 7 using the same gesture to reveal Control Center.

My fix for iOS 8 was to add the following code to my application delegate's applicationWillResignActive and applicationDidBecomeActive methods.

- (void)applicationWillResignActive:(UIApplication *)application
{
    [application beginIgnoringInteractionEvents];
    [UIView animateWithDuration:0.25 animations:^{
        for (UIWindow *aWindow in application.windows)
        {
            aWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
        }
    }];
}


- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [UIView animateWithDuration:0.25 animations:^{
        for (UIWindow *aWindow in application.windows)
        {
            aWindow.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
        }
    } completion:^(BOOL finished) {
        [application endIgnoringInteractionEvents];
    }];
}

This code basically shuts off all interaction for my app when it resigns active state. I also decided to set the tint mode to dimmed for all windows, which is my own choice to help the user understand my toolbar items and other UI that uses tintColor is not active.

When my app becomes active again, the app ends ignoring interaction events and restores the tint mode for windows back to automatic.

Hope this helps you.

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