Quote:
Originally Posted by dana0550
Hello Everyone,
I am not really sure where to start with this and I would like to fully understand what I am doing so that is why I am turning to you guys and girls.
I have a main view in an application, in this view there are 2 views embedded within the parent view. To paint a clearer picture the 2 embedded views are 300x200.
Now my question is how do I add an XIB file into one of the views. The reason why I am asking this is because the top view is a table view. I do not want the main window of the project to be of UITableView class. I would like it to remain of UIView.
Therefore I am attempting to reference the TableView.xib into the small view in the main view.
If I am approaching this the wrong way please feel free to let me know, if this is doable then what is the best way?
I though of using addSubview, but it is not a subview that I am am trying to add. I need to add an xib to the view.
Any advice is appreciated.
Dana
P.S. I did not add code yet because I am just starting this app.
|
It does sound like you are going about this the wrong way.
A typical iOS app has one or more view controllers (UIViewController objects)
A view controller maintains an entire screen. It has a "main" view that is the size of the whole screen, and then some number of subviews that contain things like table views, buttons, image views, etc.
To add a table view to a view controller, you would drag a table view object into the view controller's main view in interface builder. You can size it to take up the whole screen, or just part of then screen. You'd then add the buttons and other views that would make up the window.
Views are arranged in a hierarchy. Views contain other views, which in turn can contain other views. It is possible to add a view and it's subiviews to a window's existing set of views by loading it from a nibfile, but that's unusual, and fairly advanced. If you're just starting out, you're almost certainly on the wrong track if you're wanting to do that. Start out by building your view controller's views using a nib file in interface builder.