From d44fd7875aa487a0200246a453f819a826803798 Mon Sep 17 00:00:00 2001 From: Rodrigo Fontes Date: Fri, 24 Jan 2014 15:35:11 -0200 Subject: [PATCH 1/2] Add new method with delegate to intercept done button touch fix #3 --- MMPickerView/MMPickerView.h | 12 ++++++++++++ MMPickerView/MMPickerView.m | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/MMPickerView/MMPickerView.h b/MMPickerView/MMPickerView.h index abbf7c1..71f7439 100644 --- a/MMPickerView/MMPickerView.h +++ b/MMPickerView/MMPickerView.h @@ -19,6 +19,12 @@ extern NSString * const MMtoolbarBackgroundImage; extern NSString * const MMtextAlignment; extern NSString * const MMshowsSelectionIndicator; +@protocol MMPickerViewDelegate + +- (void)didDismissPickerView; + +@end + @interface MMPickerView: UIView +(void)showPickerViewInView: (UIView *)view @@ -26,6 +32,12 @@ extern NSString * const MMshowsSelectionIndicator; withOptions: (NSDictionary *)options completion: (void(^)(NSString *selectedString))completion; ++(void)showPickerViewInView:(UIView *)view + withDelegate:(id)delegate + withStrings:(NSArray *)strings + withOptions:(NSDictionary *)options + completion:(void (^)(NSString *))completion; + +(void)showPickerViewInView: (UIView *)view withObjects: (NSArray *)objects withOptions: (NSDictionary *)options diff --git a/MMPickerView/MMPickerView.m b/MMPickerView/MMPickerView.m index 0986641..8318c86 100644 --- a/MMPickerView/MMPickerView.m +++ b/MMPickerView/MMPickerView.m @@ -21,6 +21,7 @@ @interface MMPickerView () +@property (strong, nonatomic) id pickerViewDelegate; @property (nonatomic, strong) UILabel *pickerViewLabel; @property (nonatomic, strong) UIView *pickerViewLabelView; @property (nonatomic, strong) UIView *pickerContainerView; @@ -71,6 +72,23 @@ +(void)showPickerViewInView:(UIView *)view } ++(void)showPickerViewInView:(UIView *)view + withDelegate:(id)delegate + withStrings:(NSArray *)strings + withOptions:(NSDictionary *)options + completion:(void (^)(NSString *))completion{ + + [[self sharedView] initializePickerViewInView:view + withArray:strings + withOptions:options]; + + [[self sharedView] setPickerViewDelegate:delegate]; + [[self sharedView] setPickerHidden:NO callBack:nil]; + [self sharedView].onDismissCompletion = completion; + [view addSubview:[self sharedView]]; + +} + +(void)showPickerViewInView:(UIView *)view withObjects:(NSArray *)objects withOptions:(NSDictionary *)options @@ -89,8 +107,18 @@ +(void)showPickerViewInView:(UIView *)view #pragma mark - Dismiss Methods -+(void)dismissWithCompletion:(void (^)(NSString *))completion{ - [[self sharedView] setPickerHidden:YES callBack:completion]; ++(void)dismissWithCompletion:(void (^)(NSString *))completion +{ + [[self sharedView] setPickerHidden:YES callBack:completion]; + [self performSelector:@selector(callPickerViewDismissDelegate:) withObject:nil afterDelay:0.3]; +} + ++ (IBAction)callPickerViewDismissDelegate:(id)sender +{ + if ([self sharedView].pickerViewDelegate) + { + [[self sharedView].pickerViewDelegate didDismissPickerView]; + } } -(void)dismiss{ From 4335184e843d3179a9143d60f47dcc59e3f1b72b Mon Sep 17 00:00:00 2001 From: Rodrigo Fontes Date: Tue, 4 Feb 2014 09:02:45 -0200 Subject: [PATCH 2/2] fix Width on iPad #11 --- MMPickerView/MMPickerView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MMPickerView/MMPickerView.m b/MMPickerView/MMPickerView.m index 8318c86..6fc5b8a 100644 --- a/MMPickerView/MMPickerView.m +++ b/MMPickerView/MMPickerView.m @@ -208,7 +208,7 @@ -(void)initializePickerViewInView: (UIView *)view [self addSubview:_pickerViewContainerView]; //PickerView Container with top bar - _pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, _pickerViewContainerView.bounds.size.height - 260.0, 320.0, 260.0)]; + _pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, _pickerViewContainerView.bounds.size.height - 260.0, _pickerViewContainerView.bounds.size.width, 260.0)]; //Default Color Values (if colors == nil) @@ -301,7 +301,7 @@ -(void)initializePickerViewInView: (UIView *)view */ //Add pickerView - _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 320.0, 216.0)]; + _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, _pickerViewContainerView.bounds.size.width, 216.0)]; [_pickerView setDelegate:self]; [_pickerView setDataSource:self]; [_pickerView setShowsSelectionIndicator: _pickerViewShowsSelectionIndicator];//YES];