Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

objective c - How To Dynamically change the contentSize of UIPopoverController?

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

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

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.

It didn't.

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

Appendix: enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
}

Hope this will help for iOS 7 user.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...