Newbie Cocoa Touch question:
I'm aiming for an interface with a UIPickerView and a UIButton.
The picker needs a delegate and dataSource, which I originally wrote as a separate PickerController class implementing the right protocols. However, I'm now unsure as to how to use interface builder to link everything up.
If I have a separate .xib file for the PickerController (with just a UIPickerView in it), and add the PickerController view as a subview in the main controller, the UIPickerView is displayed correctly, but the UIButton (which is in the main .xib file) is not. It's as if add the PickerController view takes over the whole window and obscures the main view.
I tried getting rid of the separate .xib file, and instead adding the UIPickerView directly into the main .xib file. However, with that configuration, I'm not sure how to set up the delegate and dataSource, as the file's owner (the main controller) is different from the <UIPickerViewDataSource, UIPickerViewDelegate>
class I wrote (the PickerController).
Some help with the following would be great:
- should I have a separate class per-UIPickerView?
- should I have a separate .xib file per-UIPickerView?
- if the delegate and dataSource are in a different class to the file's owner, how do I connect them?
- can I add a subview to the main view without it interfering with / obscuring elements in the main view?