Skip to content

Commit

Permalink
add additional check for ipad (try to fix #18 )
Browse files Browse the repository at this point in the history
  • Loading branch information
skywinder committed Aug 21, 2014
1 parent 3dc81e6 commit 86d08ed
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Pickers/AbstractActionSheetPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ BOOL isIPhone4()
}

#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad


@interface AbstractActionSheetPicker ()

Expand Down Expand Up @@ -381,9 +383,16 @@ - (UIBarButtonItem *)createButtonWithType:(UIBarButtonSystemItem)type target:(id

- (CGSize)viewSize
{
if ( ![self isViewPortrait] )
return CGSizeMake(IS_WIDESCREEN ? 568 : 480, 320);
return CGSizeMake(320 , IS_WIDESCREEN ? 568 : 480);
if ( IS_IPAD )
{
if ( [self isViewPortrait] )
return CGSizeMake(320 , 480);
return CGSizeMake(480, 320);
}

if ( [self isViewPortrait] )
return CGSizeMake(320 , IS_WIDESCREEN ? 568 : 480);
return CGSizeMake(IS_WIDESCREEN ? 568 : 480, 320);
}

- (BOOL)isViewPortrait
Expand Down Expand Up @@ -413,7 +422,7 @@ - (void)presentPickerForView:(UIView *)aView
{
self.presentFromRect = aView.frame;

if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
if ( IS_IPAD )
[self configureAndPresentPopoverForView:aView];
else
[self configureAndPresentActionSheetForView:aView];
Expand Down

0 comments on commit 86d08ed

Please sign in to comment.