在 uipopovercontroller 中推送新的 tableViewController 会导致弹出框调整大小
我找到了这个线程,但它仍然没有解决我的问题。 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我使用
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 asetPopoverContentSize: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 theUINavigationController
stack, so another message send may be needed. Maybe each view controller that may appear in the popup will send thesetPopoverContentSize:animated:
message in itsviewWillAppear:
method. Each will also have a reference to the popover controller.您所要做的就是:
- 在 popOvers contentView 的 viewWillAppear 方法中,添加下面给出的代码片段。首次加载时,您必须指定 popOver 的大小。
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.