I have a table view controller which get it's content set after viewDidLoad
. When setting the new content I calculate the preferredContentSize
. Before I present the popover I can query the preferredContentSize
of my view controller, which is correct. But after the presentation I get the standard size of the popover (320x480). If I use setPopoverContentSize:animated:
with the before queried values everything works.
My question now is why doesn't it respect the preferredContentSize
right in the beginning? What I'm doing wrong?
Now I had the same problem another time. If I put my table height calculation into viewWillAppear
than it works:
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
TableView.LayoutIfNeeded ();
this.PreferredContentSize = new SizeF (320f, TableView.ContentSize.Height);
}
The code is in C# but you can easily convert it to Objective-C or Swift.