Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ListPicker.m #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/ios/ListPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)showPicker:(CDVInvokedUrlCommand*)command {
[toolbar setItems:buttons animated:YES];

// Initialize the picker
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40.0f, self.viewSize.width, 216)];
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 22.0f, self.viewSize.width, 216)];
self.pickerView.showsSelectionIndicator = YES;
self.pickerView.delegate = self;

Expand All @@ -82,7 +82,7 @@ - (void)showPicker:(CDVInvokedUrlCommand*)command {
}

// Initialize the View that should conain the toolbar and picker
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.viewSize.width, 260)];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, self.viewSize.height - 260, self.viewSize.width, 260)];
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
[view setBackgroundColor:[UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0]];
}
Expand Down Expand Up @@ -307,31 +307,32 @@ - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)co

- (CGSize)viewSize
{
CGSize winSize = [UIApplication sharedApplication].keyWindow.rootViewController.view.frame.size;
if ( IS_IPAD )
{
return CGSizeMake(320, 320);
}

#if defined(__IPHONE_8_0)
#if defined(__IPHONE_8_0)
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
//iOS 7.1 or earlier
if ( [self isViewPortrait] )
return CGSizeMake(320 , IS_WIDESCREEN ? 568 : 480);
return CGSizeMake(IS_WIDESCREEN ? 568 : 480, 320);

return CGSizeMake(winSize.width , IS_WIDESCREEN ? 568 : winSize.height);
return CGSizeMake(IS_WIDESCREEN ? 568 : MAX(winSize.width, winSize.height), MIN(winSize.width , winSize.height));
}else{
//iOS 8 or later
return [[UIScreen mainScreen] bounds].size;
}
#else
if ( [self isViewPortrait] )
return CGSizeMake(320 , IS_WIDESCREEN ? 568 : 480);
return CGSizeMake(IS_WIDESCREEN ? 568 : 480, 320);
#endif
#else
if ( [self isViewPortrait] )
return CGSizeMake(320 , IS_WIDESCREEN ? 568 : 480);
return CGSizeMake(IS_WIDESCREEN ? 568 : MAX(winSize.width, winSize.height), MIN(winSize.width, winSize.height));
#endif
}

- (BOOL) isViewPortrait {
return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);
}

@end
@end