Skip to content

Commit

Permalink
Merge pull request #278 from airdrummingfool/disable-popovers
Browse files Browse the repository at this point in the history
Adding the ability to disable popover behavior on iPad per picker instance
  • Loading branch information
skywinder committed May 30, 2016
2 parents 30d11d4 + 5ce5ea7 commit d8bc585
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Pickers/AbstractActionSheetPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static NSString *const kActionTarget = @"buttonActionTarget";
@property (nonatomic, retain) Class popoverBackgroundViewClass; //allow popover customization on iPad
@property (nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations; // You can set your own supportedInterfaceOrientations value to prevent dismissing picker in some special cases.
@property (nonatomic) TapAction tapDismissAction; // Specify, which action should be fired in case of tapping outside of the picker (on top darkened side). Default is TapActionNone.
@property (nonatomic) BOOL popoverDisabled; // Disable popover behavior on iPad

// For subclasses.
- (instancetype)initWithTarget:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin;
Expand Down
7 changes: 4 additions & 3 deletions Pickers/AbstractActionSheetPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ - (instancetype)init {
if (self) {
self.presentFromRect = CGRectZero;
self.popoverBackgroundViewClass = nil;
self.popoverDisabled = NO;

#pragma clang diagnostic push
#pragma ide diagnostic ignored "UnavailableInDeploymentTarget"
Expand Down Expand Up @@ -260,7 +261,7 @@ - (void)showActionSheetPicker {
}
[masterView addSubview:_pickerView];

if (![MyPopoverController canShowPopover] && !self.pickerBackgroundColor && [self.pickerBlurRadius intValue] > 0) {
if ((![MyPopoverController canShowPopover] || self.popoverDisabled) && !self.pickerBackgroundColor && [self.pickerBlurRadius intValue] > 0) {
[self blurPickerBackground];
} else {
[self presentPickerForView:masterView];
Expand Down Expand Up @@ -611,7 +612,7 @@ - (void)blurPickerBackground {

- (CGSize)viewSize {
if (IS_IPAD) {
if ([MyPopoverController canShowPopover])
if (!self.popoverDisabled && [MyPopoverController canShowPopover])
return CGSizeMake(320, 320);
return [UIApplication sharedApplication].keyWindow.bounds.size;
}
Expand Down Expand Up @@ -657,7 +658,7 @@ - (id)storedOrigin {
- (void)presentPickerForView:(UIView *)aView {
self.presentFromRect = aView.frame;

if ([MyPopoverController canShowPopover])
if (!self.popoverDisabled && [MyPopoverController canShowPopover])
[self configureAndPresentPopoverForView:aView];
else
[self configureAndPresentActionSheetForView:aView];
Expand Down

0 comments on commit d8bc585

Please sign in to comment.