【问题标题】:iphone detect shake throughout appiphone检测整个应用程序的抖动
【发布时间】:2014-02-21 02:51:30
【问题描述】:

我需要一个功能来检测抖动,而不必在每个视图控制器中添加- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event。 但是当我将函数添加到 appDelegate 时,没有检测到运动。 我试过NSNotificationCenter 无济于事。我有大量的 viewController,给它们添加 motionEnded 方法会很乏味……

有什么想法吗?

【问题讨论】:

    标签: ios iphone motion-detection


    【解决方案1】:

    您可以在 AppDelegate.window 中添加 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event。

    ps: 子类化 UIWindow

    【讨论】:

      【解决方案2】:

      创建一个 BaseViewController,将您的抖动检测方法放在那里并让每个控制器都继承自它。

      【讨论】:

        猜你喜欢
        • 2021-11-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多