ARVideoKit icon indicating copy to clipboard operation
ARVideoKit copied to clipboard

Bugs when app is landscape mode

Open joyjones opened this issue 7 years ago β€’ 6 comments

unadjustednonraw_thumb_34c9

Project settings: image

UIViewController setups: image

joyjones avatar Feb 02 '18 07:02 joyjones

@joyjones,

Please make sure to add the following line in your AppDelegate file

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return ViewAR.orientation
}

AFathi avatar Feb 02 '18 14:02 AFathi

@AFathi thx, but ViewAR.orientation only returns "portrait", while i want to use "landscape right" mode in my app, can't it support this?

joyjones avatar Feb 07 '18 02:02 joyjones

@joyjones, It will only return portrait when the user is in a UIViewController that contains an AR scene. However, if you want to support landscape right you may use the following option to specify which objects you want to view in landscape mode while in a UIViewController that contains an AR scene:

recorder?. inputViewOrientationMode = .manual(subviews:[button1, icon2, captureBtn])

Please check ARView and ARInputViewOrientationMode options.

I hope that helped :)

-Ahmed

AFathi avatar Feb 07 '18 16:02 AFathi

The landscape problem seems to be ARKit's bug. Not specifically in ARVideoKit, we can fix it by rotating camera image by setting background.contents. However, this solution makes app slower but we don't need to rotate views manually in deviceDidRotate

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
    guard let capturedImage = sceneView.session.currentFrame?.capturedImage else {
        return
    }
    let ciImage = CIImage(cvPixelBuffer: capturedImage)
    let orientation = CGImagePropertyOrientation.from(statusBarOrientation: UIApplication.shared.statusBarOrientation)
    let result = ciImage.oriented(orientation)
    if let cgImage = self.convertCameraImageContext.createCGImage(result, from: result.extent) {
        sceneView.scene.background.contents = cgImage
    }
}

ryohey avatar Jul 11 '18 07:07 ryohey

Has anyone managed to get this to work in LandscapeRight? I've tried all the above and the video is still in portrait mode with the background rotated and the overlaying scene squished to fit.

kallipigous avatar Feb 14 '19 00:02 kallipigous

Having this issue with the example app on an iPad mini

derrickstaten avatar May 08 '22 16:05 derrickstaten