Robert
Robert

Reputation: 5302

Creating UIViews programmatically

I have an iPad app which downloads and displays documents from a web server (ASP.Net / C#). The documents are split into categories, each of which is represented by a tab on a tab bar controller.

When the user taps a tab, a view controller displaying a grid-view of documents for that category is displayed.

I put this together via interface builder and each category is hard-coded.

However, I'd like to be able to create a new category on the web service and then have the the app programmatically create a new tab (with the appropriate label and icon) and associated views for that category, from parameters passed in from the web service.

Does anyone know if this is possible or does it have to be done from interface builder?

Upvotes: 0

Views: 955

Answers (1)

mlstudent
mlstudent

Reputation: 959

The basic steps would be something like this:

-in the app delegate or somewhere before initializing and setting the tab bar, make a call to download the image and info

-set the tab bar programatically ala Programmatically Setting UITabBar Titles, based on the data you downloaded

-you could reuse the same view controller for each tab if the layout is the same, and simply have a property for each instance of the view controller saying where to get data from.

Upvotes: 2

Related Questions