Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPIckerView in UIPopoverController

I'm not trying to resize the PickerView's height. I'm fine with having the default size, which I believe is 320 x 216. I created this code to present a pickerView in my popovercontroller, however, I get these messages on the console:

2

011-06-30 13:18:28.125 MiGenome[64357:207] -[UIPickerView setFrame:]: invalid height value 1024.0 pinned to 216.0 
2011-06-30 13:18:28.126 MiGenome[64357:207] -[UIPickerView setFrame:]: invalid height value 448.0 pinned to 216.0 
2011-06-30 13:18:28.127 MiGenome[64357:207] -[UIPickerView setFrame:]: invalid height value -16.0 pinned to 162.0 

I don't know why I get this since I'm trying to use the picker default size in the popover. Here's my code. Thanks.

- (IBAction)presentSortPopover {
    UIViewController *sortViewController = [[UIViewController alloc] init];

    UIPickerView *sortPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, sortViewController.view.bounds.size.width, sortViewController.view.bounds.size.height)];
    sortViewController.view = sortPickerView;
    sortViewController.contentSizeForViewInPopover = CGSizeMake(320, 216);
    sortPickerView.delegate = self;
    sortPickerView.dataSource = self;
    sortPickerView.showsSelectionIndicator = YES;

    self.SortPopover = [[UIPopoverController alloc] initWithContentViewController:sortViewController];
    [self.SortPopover presentPopoverFromRect:_sortButtonPop.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    [sortPickerView release];
    [sortViewController release];
}
like image 209
Crystal Avatar asked Jun 30 '11 20:06

Crystal


2 Answers

I had the same problem until I embedded the UIPickerView in a generic UIView with the same dimensions (0, 0, 320, 216), and set the view controller's view property to the UIView.

Also, I used the setPopoverContentSize:animated: method on the UIPopoverViewController to set the popover dimensions, rather than setting it on the UIViewController.

Hope that helps.

like image 130
Simon Lawrence Avatar answered Sep 17 '22 12:09

Simon Lawrence


I think this line is the culprit.

UIPickerView *sortPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, sortViewController.view.bounds.size.width, sortViewController.view.bounds.size.height)];

try

UIPickerView *sortPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
like image 36
NWCoder Avatar answered Sep 17 '22 12:09

NWCoder