gpt4 book ai didi

ios - UIPopoverController 太大,UIPickerView 太小

转载 作者:可可西里 更新时间:2023-11-01 17:02:13 28 4
gpt4 key购买 nike

我在 UIPopoverController 中显示了一个 UIPickerViewUIPickerView 的尺寸为:320x216。出于某种原因,UIPickerView 似乎是正常高度的 3/5,而 UIPopoverController 一直延伸到屏幕底部。

请看下面的代码。

谢谢!

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];

最佳答案

“压缩”选择器 View 的原因似乎是这一行:

[pickerController setView:self.picker];

相反,将选择器 View 添加为 subview :

[pickerController.view addSubview:picker];


接下来,要固定弹出高度,请在呈现之前设置 popoverContentSize:

pickerPopover.popoverContentSize = picker.frame.size;


此外,从这里修复选择器 View 的框架:

CGRectMake(0, self.view.bounds.size.height+44, 320, 216)

为此:

CGRectMake(0, 0, 320, 216)

关于ios - UIPopoverController 太大,UIPickerView 太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8088902/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com