ARVideoKit
ARVideoKit copied to clipboard
Bugs when app is landscape mode

Project settingsοΌ

UIViewController setups:

@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 thx, but ViewAR.orientation only returns "portrait", while i want to use "landscape right" mode in my app, can't it support this?
@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
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
}
}
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.
Having this issue with the example app on an iPad mini