简体   繁体   English

CoreMotion-确定是否在iOS设置中禁用运动的方法?

[英]CoreMotion - way to determine if motion is disabled in iOS Settings?

On iOS 7 the user can choose disable device motion in Settings -> General -> Accessibility -> Reduce Motion. 在iOS 7上,用户可以在“设置”->“常规”->“辅助功能”->“减少运动”中选择“禁用设备运动”。

I am creating a UI effect based on UITableView scrolling, so I am not using CMMotionManager or the CoreMotion framework to create any motion effects. 我正在基于UITableView滚动创建UI效果,因此我没有使用CMMotionManagerCoreMotion框架来创建任何运动效果。

However, I would like to respect the user's settings and not create the motion effect if the user has turned on Reduce Motion in Settings. 但是,如果用户已在“设置”中启用“ Reduce Motion ”,则我想尊重用户的设置,而不创建运动效果。

CMMotionManager includes an instance method deviceMotionActive to check for whether it's active (I'm assuming this is the correct check), however, I'd prefer not having to initialize the manager just to do this check, sadly I cannot find any documentation about a class method that would return a similar boolean, sort of like there exist class methods on MFMessageComposeViewController to check for iMessage/SMS availability ( +(BOOL)canSendText ) and so on. CMMotionManager 包含一个实例方法 deviceMotionActive来检查它是否处于活动状态(我假设这是正确的检查),但是,我宁愿不必初始化管理器来进行此检查,可悲的是,我找不到任何有关将返回类似布尔值的类方法, MFMessageComposeViewController上存在类方法来检查iMessage / SMS可用性( +(BOOL)canSendText ),依此类推。

Thanks! 谢谢!

You are confusing two separate things called "motion". 您正在混淆称为“运动”的两个独立的事物。 CMMotionManager is used to access the sensors, such as the gyroscope and accelerometer, that report how a user physically moves a device. CMMotionManager用于访问传感器,例如陀螺仪和加速度计,这些传感器报告用户如何物理移动设备。 It has nothing to do with the motion effects, like UIMotionEffect objects, that are used in animating views. 与动画视图中使用的运动效果(如UIMotionEffect对象)无关。

The deviceMotionActive method merely indicates whether your app is currently registered for receiving motion updates from CoreMotion. deviceMotionActive方法仅指示您的应用当前是否已注册以接收来自CoreMotion的运动更新。 This will only be true if your app has called one of the CMMotionManager startXXXUpdate methods. 仅当您的应用程序调用了CMMotionManager startXXXUpdate方法之一时,这才是正确的。 Again, it has nothing to do with user settings or UIMotionEffect objects. 同样,它与用户设置或UIMotionEffect对象无关。

UPDATE: As John mentions in the comments, there appears to be an API for this in iOS 8: See stackoverflow.com/a/25453082/2904769 . 更新:正如John在评论中提到的那样,iOS 8中似乎有一个用于此的API:请参见stackoverflow.com/a/25453082/2904769。

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

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