2016-10-14 7 views
0

CMMotionManager를 사용하여 장면 킷에서 카메라 시점의 태도를 업데이트하려고합니다. 기본 참조를 사용하여 다음 코드를 사용할 수 있습니다.스위프트 3을 사용하여 IOS 10 coremotion에서 태도 참조 프레임을 선택했습니다.

manager.deviceMotionUpdateInterval = 0.01 
manager.startDeviceMotionUpdates(using: CMAttitudeReferenceFrameXMagneticNorthZVertical, to: motionQueue, withHandler:{ deviceManager, error in 
      if (deviceManager?.attitude) != nil { 
       let rotation = deviceManager?.attitude.quaternion 

       OperationQueue.main.addOperation { 
        self.cameraNode.rotation = SCNVector4(rotation!.x,rotation!.y,rotation!.z,rotation!.w) 
       } 
      } 

     }) 

내가 나타나는 오류는 다음과 같습니다 :

Use of unresolved identifier 'CMAttitudeReferenceFrameXMagneticNorthZVertical' 

내가 유사한 오류 메시지를 얻을 아래 그림과 같이

manager.deviceMotionUpdateInterval = 0.01 
manager.startDeviceMotionUpdates(to: motionQueue, withHandler:{ deviceManager, error in 
       if (deviceManager?.attitude) != nil { 
        let rotation = deviceManager?.attitude.quaternion 

        OperationQueue.main.addOperation { 
         self.cameraNode.rotation = SCNVector4(rotation!.x,rotation!.y,rotation!.z,rotation!.w) 
        } 
       } 

     }) 

내가 선택한 참조 프레임 작업 할 startDeviceMotionUpdates를 얻을 수 있지만 드릴 수 없습니다 다른 참조 프레임에 대해서도 마찬가지입니다. 누구든지 startDeviceMotionUpdates 함수에 "using :"매개 변수를 사용하는 것에 대해 알 수 있습니까? 내가 찾은 모든 예제는 이전 버전의 신속하거나 객관적인 C 용이므로 Swift 3 구문을 이해하지 못하는 문제 일 가능성이 큽니다.

답변

0

나는 새로운 인수를 사용하여 새로운 CMAttitudeReferenceFrame 구조체의 멤버가 필요하다는 것을 알아 냈습니다.

manager.deviceMotionUpdateInterval = 0.01 
manager.startDeviceMotionUpdates(using: CMAttitudeReferenceFrame.xMagneticNorthZVertical 
      ,to: motionQueue, withHandler:{ 
      deviceManager, error in 
      if (deviceManager?.attitude) != nil { 
       let rotation = deviceManager?.attitude.quaternion 

       OperationQueue.main.addOperation { 
        self.cameraNode.rotation = SCNVector4(rotation!.x,rotation!.y,rotation!.z,rotation!.w) 
       } 
      } 

     }) 

여기에는 "CMAttitudeReferenceFrameXMagneticNorthZVertical"로 상수 직접 사용

허용 이전 버전에서의 변화는 다음과 같이, 즉 전달되어야
관련 문제