UIPopoverController 在 pushViewController 上自动调整到最大高度 [英] UIPopoverController automatically resizing to max height on pushViewController

查看:22
本文介绍了UIPopoverController 在 pushViewController 上自动调整到最大高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 UINavigationController 的弹出框.我可以很好地显示弹出窗口,并且它包含 navController 就好了.navController 包含一个 tableView,当我选择一个项目时,它会创建一个新的详细视图:

I have a popover containing a UINavigationController. I can display the popover fine, and it contains the navController just fine. The navController contains a tableView and when I select an item it creates a new detail view:

     DeviceDetailViewController *detailViewController = 
[[[DeviceDetailViewController alloc] initWithNibName:@"DeviceDetailViewController" bundle:nil] autorelease];

然后我将它推送到新的视图控制器:

I then push it the new view controller:

    [self.navigationController pushViewController:detailViewController animated:YES];

这是出现问题的时间: 推送新视图后,弹出窗口将调整为 iPad 上可用的最大高度.

This is when the problem occurs: after pushing the new view the popover resizes to the maximum height available on the iPad.

我尝试将 xib 中所有视图的高度设置为固定高度而不是灵活高度.我已经尝试明确设置弹出框的高度.我也尝试使用不同的视图控制器作为子视图.问题仍然存在:每当将新视图推送到导航控制器时,弹出框想要自动将自身调整到最大高度.

I have tried setting the height of all the views in the xib to fixed height rather than flexible. I have tried explicitly setting the height of the popover. I have also tried using different view controllers as the child view. The problem remains: the popover wants to resize itself to max height automatically whenever a new view is pushed to the navigation controller.

这是一个问题,它讨论了当推动新观点:

Here's a question which discusses trying to deliberately control the size of the popover when pushing new views:

我认为这可能是控制大小的蛮力方法.然而,奇怪的是,它实际上会导致一些快速的图形怪癖(好像视图刚被动画化),然后继续如上所述调整大小.

I thought this might be a brute force method to control the size. Strangely enough, though, it actually causes some quick graphics quirks (as if the view were being freshly animated in) followed by continuing to resize as described above.

换句话说,某种东西实际上是在迫使弹出框达到它的最大高度,而且它似乎发生在所有委托方法都被调用之后.

In other words, something is literally forcing the popover to its maximum height, and it seems to occur after all delegate methods have been called.

是导航控制器吗?有人见过这种东西吗?

Is it the navigation controller? Has anyone seen this kind of thing?

推荐答案

在我遇到同样的问题后,这为我解决了(巧合的是今天):

This fixed it for me after I had the same issue (coincidently also today):

EDIT :由于 contentSizeForViewInPopoveriOS7.0 中被弃用,所以使用 preferredContentSize.

EDIT : As contentSizeForViewInPopover is deprecated in iOS7.0 so use preferredContentSize.

以下原始答案:

在您的 detailViewController 中添加:

- (void)viewWillAppear:(BOOL)animated {

    CGSize size = CGSizeMake(320, 480); // size of view in popover
    self.contentSizeForViewInPopover = size;

    [super viewWillAppear:animated];

}

您还想添加类似于原始 DeviceDetailViewController 的内容,以防止在点击背面 NavbarItem 时调整大小.

You also want to add something similar to your original DeviceDetailViewController to prevent resizing when tapping the back NavbarItem.

这篇关于UIPopoverController 在 pushViewController 上自动调整到最大高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆