Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
无论显示的视图如何,都可以检测到摇晃手势吗?
每当用户摇动设备时,我都想转到应用程序的主页。除了在每个 UIView 中放入方法之外,还有其他解决方案-motionBegan:withEvent:吗?
-motionBegan:withEvent:
创建一个子类UIViewController,比如说UIShakeViewController,并从UIShakeViewController.
UIViewController
UIShakeViewController
然后,在 中UIShakeViewController,实现您的抖动检测方法等。这样,您的所有视图控制器都具有该功能,但您只需实现一次检测代码。