在 uipopovercontroller 中推送新的 tableViewController 会导致弹出框调整大小

发布于 2024-12-13 08:16:27 字数 864 浏览 5 评论 0原文

我找到了这个线程,但它仍然没有解决我的问题。 UIPopoverController 自动调整到 PushViewController 上的最大高度

我有一个 UIPopoverController推动导航控制器。当我呈现此弹出窗口时,我将 contentSizeForPopover 设置为 340,340。效果很好。在弹出窗口中,我有一个按钮,它将新的 UITableViewController 推送到已经存在的 UIPopoverController 中(下面的 tableViewController 代码)。

UITableViewController *contentView = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
contentView.tableView.delegate = self;
contentView.tableView.dataSource = self;
[self.navigationController pushViewController:contentView animated:YES];
[contentView release];

当 tableView 被推送时,高度会增长到 iPad 的最大高度。当我按下后退按钮时,高度仍然是最大高度,并且不会返回到最初创建 UIPopoverController 时定义的 340,340 高度。有没有办法为我创建的新 tableView 再次设置此值?谢谢。

I found this thread, but it still doesn't fix my problem. UIPopoverController automatically resizing to max height on pushViewController

I have a UIPopoverController that pushes a navigationcontroller. When I present this popover, I set the contentSizeForPopover to 340,340. That works fine. In the popover, I have a button, that pushes a new UITableViewController into the already existing UIPopoverController (code below for the tableViewController).

UITableViewController *contentView = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
contentView.tableView.delegate = self;
contentView.tableView.dataSource = self;
[self.navigationController pushViewController:contentView animated:YES];
[contentView release];

When the tableView gets pushed, the height grows to the max height of the iPad. When I press the back button, the height still is at the max height and does not go back to the 340,340 height that was defined when the UIPopoverController was originally created. Is there a way to set this value again for the new tableView I created? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

So尛奶瓶 2024-12-20 08:16:27

根据我使用 UIPopoverController 对象的经验,每当将新内容添加到弹出窗口时,弹出窗口似乎都会使用最大高度。每次更改内容时,我都会向弹出窗口控制器发送一条 setPopoverContentSize:animated: 消息,这当然要求我在每个可能导致弹出窗口调整大小的对象中保留对该弹出窗口控制器的引用。您可以在问题中的示例代码之后添加该消息发送,以防止弹出窗口调整大小,但当您从 UINavigationController 堆栈中弹出此视图时,它仍然可能会调整大小,因此可能会发送另一条消息需要。也许弹出窗口中可能出现的每个视图控制器都会在其 viewWillAppear: 方法中发送 setPopoverContentSize:animated: 消息。每个还将有一个对弹出控制器的引用。

In my experience with UIPopoverController objects, the popover seems to use the maximum height whenever new content is added to the popover. I send the popover controller a setPopoverContentSize:animated: message every time I change the content, which of course requires me to keep a reference to that popover controller in every object that may cause the popover to resize. You could add that message send right after your sample code in your question to keep the popover from resizing, but it may still resize when you pop off this view from the UINavigationController stack, so another message send may be needed. Maybe each view controller that may appear in the popup will send the setPopoverContentSize:animated: message in its viewWillAppear: method. Each will also have a reference to the popover controller.

烟沫凡尘 2024-12-20 08:16:27

您所要做的就是:

- 在 popOvers contentView 的 viewWillAppear 方法中,添加下面给出的代码片段。首次加载时,您必须指定 popOver 的大小。

-(void)viewWillAppear{
CGSize size = CGSizeMake(width,height);
self.contentSizeForViewInPopover = size;
}

All that you have to do is:

-In the viewWillAppear method of the popOvers contentView, add the snippet given below. You will have to specify the popOver's size first time when it is loaded.

-(void)viewWillAppear{
CGSize size = CGSizeMake(width,height);
self.contentSizeForViewInPopover = size;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文