Created
August 1, 2017 09:18
-
-
Save frosty/f039793936682651e533272ae12534ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Example/WPMediaPicker/DemoViewController.m b/Example/WPMediaPicker/DemoViewController.m | |
index 9140fb5..d6b7c3c 100644 | |
--- a/Example/WPMediaPicker/DemoViewController.m | |
+++ b/Example/WPMediaPicker/DemoViewController.m | |
@@ -275,6 +275,7 @@ - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField | |
{ | |
if (textField == self.quickInputTextField) { | |
[self setupMediaKeyboardForInputField]; | |
+ self.mediaInputViewController.options = [self selectedOptions]; | |
[self.mediaInputViewController.mediaPicker resetState:NO]; | |
} | |
return YES; | |
diff --git a/Pod/Classes/WPInputMediaPickerViewController.h b/Pod/Classes/WPInputMediaPickerViewController.h | |
index e9a8cbd..1a8112e 100644 | |
--- a/Pod/Classes/WPInputMediaPickerViewController.h | |
+++ b/Pod/Classes/WPInputMediaPickerViewController.h | |
@@ -36,6 +36,12 @@ The delegate for the WPMediaPickerViewController events | |
@property (nonatomic, readonly) WPMediaPickerViewController * _Nonnull mediaPicker; | |
/** | |
+ Options passed to the internal media picker instance. Options should be set via | |
+ this property instead of directly on the media picker itself. | |
+ */ | |
+@property (nonatomic, copy) WPMediaPickerOptions * _Nonnull options; | |
+ | |
+/** | |
A toolbar that can be used as the inputAccessoryView for this inputView. | |
*/ | |
@property (nonatomic, readonly) UIToolbar * _Nonnull mediaToolbar; | |
diff --git a/Pod/Classes/WPInputMediaPickerViewController.m b/Pod/Classes/WPInputMediaPickerViewController.m | |
index da65384..81be151 100644 | |
--- a/Pod/Classes/WPInputMediaPickerViewController.m | |
+++ b/Pod/Classes/WPInputMediaPickerViewController.m | |
@@ -14,10 +14,7 @@ @implementation WPInputMediaPickerViewController | |
- (instancetype _Nonnull )initWithOptions:(WPMediaPickerOptions *_Nonnull)options { | |
self = [super initWithNibName:nil bundle:nil]; | |
if (self) { | |
- WPMediaPickerOptions *optionsOverride = [options copy]; | |
- // Always turn off media capture in the input picker | |
- optionsOverride.allowCaptureOfMedia = NO; | |
- _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:optionsOverride]; | |
+ _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:[self overriddenOptions:options]]; | |
} | |
return self; | |
} | |
@@ -26,9 +23,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
WPMediaPickerOptions *options = [WPMediaPickerOptions new]; | |
- // Always turn off media capture in the input picker | |
- options.allowCaptureOfMedia = NO; | |
- _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:options]; | |
+ _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:[self overriddenOptions:options]]; | |
} | |
return self; | |
} | |
@@ -37,9 +32,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { | |
self = [super initWithCoder:aDecoder]; | |
if (self) { | |
WPMediaPickerOptions *options = [WPMediaPickerOptions new]; | |
- // Always turn off media capture in the input picker | |
- options.allowCaptureOfMedia = NO; | |
- _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:options]; | |
+ _mediaPicker = [[WPMediaPickerViewController alloc] initWithOptions:[self overriddenOptions:options]]; | |
} | |
return self; | |
} | |
@@ -122,5 +115,24 @@ - (void)mediaCanceled:(UIBarButtonItem *)sender { | |
} | |
} | |
+- (void)setOptions:(WPMediaPickerOptions *)options | |
+{ | |
+ self.mediaPicker.options = [self overriddenOptions:options]; | |
+} | |
+ | |
+- (WPMediaPickerOptions *)options | |
+{ | |
+ return self.mediaPicker.options; | |
+} | |
+ | |
+- (WPMediaPickerOptions *)overriddenOptions:(WPMediaPickerOptions *)options | |
+{ | |
+ WPMediaPickerOptions *optionsOverride = [options copy]; | |
+ | |
+ // Always turn off media capture in the input picker | |
+ optionsOverride.allowCaptureOfMedia = NO; | |
+ | |
+ return optionsOverride; | |
+} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment