Get device current orientation (App Extension)

后端 未结 10 1491
执笔经年
执笔经年 2020-12-09 10:02

How to get device current orientation in an App Extension, I have tried below two methods but no success.

  1. It always return UIDeviceOrientationUnknown

    <
10条回答
  •  不知归路
    2020-12-09 10:52

    In BroadcastExtension you can use sampleBuffer to understand orientation:

    if let orientationAttachment =  CMGetAttachment(sampleBuffer, RPVideoSampleOrientationKey as CFString, nil) as? NSNumber 
    {  
              let orientation = CGImagePropertyOrientation(rawValue: orientationAttachment.uint32Value)   
    }
    

提交回复
热议问题