Domanda

I am trying to create a popover that looks like the below

enter image description here

Basically, it has three main sections - a header which has some labels in it, a body and a footer which has 2 buttons. The body is made up of a variable number of ChildViewControllers.

Question

1) how should I go about doing this? I am thinking in viewWillAppear I call a web service which asynchronously returns me the number of ChildViewControllers to create. In the callback method I then create the ChildViewControllers, put them into an array and also add them as ChildViewControllers using addChildViewController. Will it be a problem adding ChildViewControllers outside of viewDidLoad or viewWillAppear etc and in the callback method?

2) this view controller is going to appear in a popover. how can I resize the popover in the view controller such that I still get to keep my header and footer (essentially only the centre portion with the varying number of childViewControllers gets adjusted.

È stato utile?

Soluzione

in the end I implemented this using a UITableViewController. The header is a UIView implemented as a table header. While the two buttons are put into a UIView as the table footer. ChildViewControllers are put into UITableViewCells. I then disabled scrolling on the UITableView.

This method made it very easy to achieve the variable height of the center portion while retaining header and footer.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top