UIPopoverController 的内容视图大小
我有一个 UIPopoverController,它是从 iPad 上的 CGRect 呈现的,如下所示:
MarkersPopViewController *markersPop = [[MarkersPopViewController alloc] initWithNibName:@"MarkersPopView" bundle:nil];
self.TestPopoverController = [[[UIPopoverController alloc] initWithContentViewController:markersPop] autorelease];
[TestPopoverController presentPopoverFromRect:CGRectMake(20, 20, 700, 500) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
我的 MarkersPopView 是容器视图,它有一个占据 .xib 大部分的 UITableView,以及一个位于 UITableView 顶部上方的 UISegmentedControl。 UITableView 使用 UITableViewCell 的自定义子类,其中每行为 (700, 100)。
当我运行我的应用程序时,PopoverController 可能只有 50 磅宽并紧贴屏幕左侧。我想让视图适合初学者的宽度,然后将其居中。 UIPopoverController 这么小有什么原因吗?我认为如果未使用 setPopoverContentSize: ,UIPopoverController 将使用内容视图的默认大小。谢谢。
I have a UIPopoverController that I present from a CGRect on iPad like so:
MarkersPopViewController *markersPop = [[MarkersPopViewController alloc] initWithNibName:@"MarkersPopView" bundle:nil];
self.TestPopoverController = [[[UIPopoverController alloc] initWithContentViewController:markersPop] autorelease];
[TestPopoverController presentPopoverFromRect:CGRectMake(20, 20, 700, 500) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
My MarkersPopView is the container view that has a UITableView that takes up the bulk of the .xib, and a UISegmentedControl just above the top of the UITableView. The UITableView uses a custom subclass of UITableViewCell where each row is (700, 100).
When I run my app, the PopoverController is probably only 50 points wide and hugs the left side of the screen. I'd like to make the view the right width for starters, and then center it. Is there a reason why the UIPopoverController is so small? I thought the UIPopoverController uses the default size of the content view if setPopoverContentSize: was not used. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传递给presentPopoverFromRect 的CGRect 是弹出框将显示在其一侧的矩形。这不是弹出框将出现的框架。。
由于您请求箭头位于弹出窗口的右侧,因此它会尝试将弹出窗口显示在 20,20,700,500 的左侧。
要在 20,20(实际上是箭头尖端所在的位置)显示弹出窗口,请传递 20,20,1,1 的 CGRect。
您可能仍需要指定 popoverContentSize。
The CGRect passed to presentPopoverFromRect is the rectangle the popover will be displayed on some side of. It's not the frame the popover will appear in.
Since you are requesting the arrow be on the right of the popover, it tries to display the popover to the left of 20,20,700,500.
To display the popover at 20,20 (actually where the arrow tip will be), pass a CGRect of 20,20,1,1.
You might still have to specify popoverContentSize.