我有一個UIPickerView
顯示在UIPopoverController
內。 UIPickerView
的尺寸爲:320x216
。出於某種原因,UIPickerView
似乎是正確高度的3/5,並且UIPopoverController
一直延伸到屏幕的底部。UIPopoverController太大,UIPickerView太小
請參閱下面的代碼。
謝謝!
self.picker = [[[UIPickerView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height+44, 320, 216)] autorelease];
self.picker.backgroundColor = [UIColor clearColor];
self.picker.showsSelectionIndicator = YES;
self.picker.delegate = self;
self.picker.dataSource = self;
self.picker.transform = CGAffineTransformMakeScale(-1, 1);
UIViewController *pickerController = [[UIViewController alloc] init];
[pickerController setView:self.picker];
UIPopoverController *pickerPopover = [[UIPopoverController alloc] initWithContentViewController:pickerController];
[pickerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
pickerPopover.delegate = self;
self.popover = pickerPopover;
[pickerController release];
[pickerPopover release];
只是爲了任何人使用Google到這一點,不要忘記你只需設置柱高度 - (CGFloat)pickerView:(UIPickerView *)pickerView ** rowHeightForComponent:**(NSInteger)component {return 30.0; }(不要忘記你的.h文件中的!) –
Fattie