mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 19:56:57 +02:00
Bug Fix: Camera preview is broken after a second try
The camera preview was set up with a wrong frame value. We wait for the first `viewDidLayoutSubviews` call before setting up the preview. #686 + fix the wrong preview layout on iPad described in PR #1372 MediaPicker xib layout fix.
This commit is contained in:
@@ -127,15 +127,11 @@ static void *RecordingContext = &RecordingContext;
|
||||
// Register album table view cell class
|
||||
[self.userAlbumsTableView registerClass:MediaAlbumTableCell.class forCellReuseIdentifier:[MediaAlbumTableCell defaultReuseIdentifier]];
|
||||
|
||||
// Adjust camera preview ratio
|
||||
[self handleScreenOrientation];
|
||||
|
||||
// Force UI refresh according to selected media types - Set default media type if none.
|
||||
self.mediaTypes = _mediaTypes ? _mediaTypes : @[(NSString *)kUTTypeImage];
|
||||
|
||||
// Check camera access before set up AV capture
|
||||
[self checkDeviceAuthorizationStatus];
|
||||
[self setupAVCapture];
|
||||
|
||||
// Set camera preview background
|
||||
self.cameraPreviewContainerView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
|
||||
@@ -161,6 +157,19 @@ static void *RecordingContext = &RecordingContext;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews
|
||||
{
|
||||
[super viewDidLayoutSubviews];
|
||||
|
||||
// Here the views frames are ready, set up the camera preview if it is not already done.
|
||||
if (!captureSession)
|
||||
{
|
||||
// Adjust camera preview ratio
|
||||
[self handleScreenOrientation];
|
||||
[self setupAVCapture];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
// Check whether destroy is required
|
||||
@@ -198,7 +207,7 @@ static void *RecordingContext = &RecordingContext;
|
||||
|
||||
// Hide the navigation bar, and force the preview camera to be at the top (behing the status bar)
|
||||
self.navigationController.navigationBarHidden = YES;
|
||||
[self scrollViewDidScroll:_mainScrollView];
|
||||
self.mainScrollView.contentOffset = CGPointMake(0, 0);
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
@@ -410,6 +419,7 @@ static void *RecordingContext = &RecordingContext;
|
||||
attribute:NSLayoutAttributeHeight
|
||||
multiplier:ratio
|
||||
constant:0.0f];
|
||||
self.cameraPreviewContainerAspectRatio.priority = 750;
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[self.cameraPreviewContainerAspectRatio]];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user