Jochen Kühner
Jochen Kühner

Reputation: 1411

Using of a ViewControler directly in XIB File. (Monotouch)

I'm developing apps with Monotouch and its working quit well.

When im working with View Controllers in Code wich load there Views directly from xib file, everything is working fine.

But i see that InterfaceBuilder also allows to put ViewControllers directly in a xib file. With this the interface Design would be much easier. But I don't know if this is supported via Monotouch, and when it is, how do I use it.

Maybe someone can help me???

Upvotes: 0

Views: 201

Answers (1)

jonathanpeppers
jonathanpeppers

Reputation: 26505

Under the "Add New" dialog, pick iPhone or iPad Controller under the MonoTouch section. This will create a YourController.cs, YourController.designer.cs, and a YourController.xib file.

Beyond that, all you should have to do is edit the XIB file which has the view as you expect and the controller as the File's Owner. If you hook up any outlets or actions, they will show up in the controller. Outlets will be properties and actions will be partial methods.

Note that not every type of controller works properly (such as UITabBarController or UISplitViewController), I've not had any issues with UIViewController or UITableViewController. For controllers that do not work in this way, it's generally just easier to create them in C#.

You can also set up additional controllers in the same XIB file. To access them, you will have to create outlets. Their views will show up for editing as you would expect in the UI tree within the XIB file.

Upvotes: 2

Related Questions