From 6f67094668f481e1f548e1912a1c638936454d7d Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 22 Aug 2017 22:42:26 +0100 Subject: [PATCH 1/3] Keep controller around. --- Example/WPMediaPicker/DemoViewController.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Example/WPMediaPicker/DemoViewController.m b/Example/WPMediaPicker/DemoViewController.m index 80069c64..306fba59 100644 --- a/Example/WPMediaPicker/DemoViewController.m +++ b/Example/WPMediaPicker/DemoViewController.m @@ -132,7 +132,11 @@ - (UITextField *)quickInputTextField { } - (void)setupMediaKeyboardForInputField { - self.mediaInputViewController = [[WPInputMediaPickerViewController alloc] init]; + if (self.mediaInputViewController) { + [self.mediaInputViewController removeFromParentViewController]; + } else { + self.mediaInputViewController = [[WPInputMediaPickerViewController alloc] init]; + } if ([self.options[MediaPickerOptionsScrollInputPickerVertically] boolValue]) { self.mediaInputViewController.scrollVertically = YES; } From 0329b82cd1588e49c920adb407ab091600b4c736 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 22 Aug 2017 22:54:23 +0100 Subject: [PATCH 2/3] Init preview layer out of main thread. --- Pod/Classes/WPMediaCapturePreviewCollectionView.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/WPMediaCapturePreviewCollectionView.m b/Pod/Classes/WPMediaCapturePreviewCollectionView.m index 1dfc68e9..fca29da3 100644 --- a/Pod/Classes/WPMediaCapturePreviewCollectionView.m +++ b/Pod/Classes/WPMediaCapturePreviewCollectionView.m @@ -30,7 +30,7 @@ - (void)commonInit self.backgroundColor = [UIColor blackColor]; _sessionQueue = dispatch_queue_create("org.wordpress.WPMediaCapturePreviewCollectionView", DISPATCH_QUEUE_SERIAL); _previewView = [[UIView alloc] initWithFrame:self.bounds]; - _previewView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _previewView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self addSubview:_previewView]; UIImage *cameraImage = [[WPMediaPickerResources imageNamed:@"gridicons-camera-large" withExtension:@"png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; @@ -101,10 +101,11 @@ - (void)startCapture } if (!self.session.isRunning || !self.captureVideoPreviewLayer.connection.enabled){ [self.session startRunning]; + AVCaptureVideoPreviewLayer * newLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session]; dispatch_async(dispatch_get_main_queue(), ^{ if (!self.captureVideoPreviewLayer || !self.captureVideoPreviewLayer.connection.enabled) { [self.captureVideoPreviewLayer removeFromSuperlayer]; - self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session]; + self.captureVideoPreviewLayer = newLayer; CALayer *viewLayer = self.previewView.layer; self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.captureVideoPreviewLayer.frame = viewLayer.bounds; From 8f246b0d44d1efa4d3a20f3c7f4dab97d80f3947 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 23 Aug 2017 23:06:32 +0100 Subject: [PATCH 3/3] Fix spaces. --- Pod/Classes/WPMediaCapturePreviewCollectionView.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/WPMediaCapturePreviewCollectionView.m b/Pod/Classes/WPMediaCapturePreviewCollectionView.m index fca29da3..991501f3 100644 --- a/Pod/Classes/WPMediaCapturePreviewCollectionView.m +++ b/Pod/Classes/WPMediaCapturePreviewCollectionView.m @@ -26,11 +26,11 @@ - (void)commonInit { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; - + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.backgroundColor = [UIColor blackColor]; _sessionQueue = dispatch_queue_create("org.wordpress.WPMediaCapturePreviewCollectionView", DISPATCH_QUEUE_SERIAL); _previewView = [[UIView alloc] initWithFrame:self.bounds]; - _previewView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _previewView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self addSubview:_previewView]; UIImage *cameraImage = [[WPMediaPickerResources imageNamed:@"gridicons-camera-large" withExtension:@"png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; @@ -49,6 +49,7 @@ - (void)dealloc - (void)layoutSubviews { [super layoutSubviews]; + self.previewView.frame = self.bounds; self.captureVideoPreviewLayer.frame = self.previewView.bounds; }