I created a form in Xamarin.Forms
and then used a PageRenderer
in Xamarin.iOS to display live camera feed using AVCaptureSession
. I set a UIView
Frame equal to the View.Frame and then added a sublayer AVCaptureSessionPreviewLayer
to that UIView
. Testing on an iPhone 7 the Camera feed takes up the entire screen but testing on an IPad the camera feed is only in the middle leaving a big margin on the left and right, but not on the top or bottom.
When debugging the Bounds that are set they equal 0, 0, 768, 1024. Even though the x and y origin are both 0 it does not start in the top left corner.
How can I fix this issue? Is there a way instead of creating a completely new UIView in the code behind I can just set the AVCaptureSessionPreviewLayer
to show inside of a Xamarin.Forms
control?
UPDATE: I added another control and set the origin to 0,0 and it's in the top left corner. So I would assume that me adding a sublayer is the cause of the improper origin and width.
ViewDidLoad
,ViewWillAppear
,ViewDidLayoutSubviews
since the view hasn't figured out it's correct dimensions untilViewWillAppear
. Something to be mindful of! - Axemasta