简体   繁体   English

iOS Control Center触摸传递到我的“滚动视图”了吗?

[英]iOS Control Center touches pass through to my Scroll View?

I have a UIScrollView that scrolls horizontally along the bottom edge of my application. 我有一个UIScrollView ,它可以沿应用程序的底部边缘水平滚动。 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. 我注意到一个错误,如果用户向上滑动以打开Control Center,Control Center会附着在他们的手指上,但是会调用我的scrollViewDidBeginDragging方法。 Trouble is, no subsequent ending method is called, meaning my scroll view thinks someone started pulling it and never stopped. 麻烦的是,没有调用任何后续的end方法,这意味着我的滚动视图认为有人开始拉它,而从未停止过。

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). 它似乎只发生在设备上,而不是在模拟器中发生(在sim中,从不调用scrollViewDidBeginDragging委托方法)。

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. 我在iOS 8上遇到了此错误。在执行从底部手势进行滑动以显示Control Center时,滚动视图和其他带有自定义手势的视图都被传递了触摸。 I had some UIButtons near the bottom of the screen that would also begin tracking. 我在屏幕底部附近有一些UIButton,它们也将开始跟踪。 None of these issues were happening with iOS 7 using the same gesture to reveal Control Center. 这些问题都没有发生在使用相同手势显示Control Center的iOS 7上。

My fix for iOS 8 was to add the following code to my application delegate's applicationWillResignActive and applicationDidBecomeActive methods. 我对iOS 8的修复是将以下代码添加到我的应用程序委托的applicationWillResignActive和applicationDidBecomeActive方法中。

- (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. 我还决定将所有窗口的色调模式设置为暗淡,这是我自己的选择,以帮助用户了解我的工具栏项目以及使用tintColor的其他UI处于未激活状态。

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. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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