如何动态更改UIPopoverController的contentSize? [英] How To Dynamically change the contentSize of UIPopoverController?

查看:273
本文介绍了如何动态更改UIPopoverController的contentSize?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 UITableView UIViewController
UIViewController 显示在 UIPopoverController 中。

I have a UIViewController that contains a UITableView. This UIViewController is being displayed in a UIPopoverController.

现在,事情是 tableView 中的项目数不是常数,我想要的大小popover(即 - popoverContentSize ),根据 tableView中的项目数量进行调整

Now, the things is that the number of items in the tableView is not constant, and I want the size of the popover (that is - the popoverContentSize), to adjust according to the number of items in the tableView

Naive,我想,如果我将在 viewDidLoad 中设置 contentSizeForViewInPopover code> tableView 与所有的项目 - 它会做到。

Naively, I was thinking that if I'll set the contentSizeForViewInPopover in viewDidLoad after I'm loading the tableView with all the items - It'll do it.

没有。

所以使它很短,我的问题是:如何直接从 contentViewController 改变 popoverContentSize code> - 提交后?

So the make it short, my question is: How can I change the popoverContentSize directly from the contentViewController - after it's been presented?

附录:

推荐答案

我可能迟到了, 7
请使用 UIPopOverViewConotroller

I might be very late to answer but for new user from iOS 7 please use the following line in your UIViewController i,e contentViewController of your UIPopOverViewConotroller

-(void) viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated]
    self.preferredContentSize=myTableView.contentSize;
}

希望这将有助于iOS 7用户。

Hope this will help for iOS 7 user.

这篇关于如何动态更改UIPopoverController的contentSize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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