문제

I want to create a customized UIView class (a static lib) for some app developers. I have created CMMotionManager instance in my code. I've found that if an app developer also creates the CMMotionManager instance in his code, one of our CMMotionManager instance will fail to handle the gyro/accelerometer values. I realize that the UIWebview can get these values (e.g. javascript code: window.ondevicemotion = function(e) {...}) while the app is getting them, I think there might be a way to avoid this conflict. Any ideas about how to avoid this conflict?

도움이 되었습니까?

해결책

As with the CLLocation manager you should only implement one instance of CMMotionManager per app, I would recommend creating a singleton class and accessing your CMMotionManager from there, see this post

CMMotionManager is a global resource? What does this means?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top