I have a nib call "Hello.xib", and I have a HelloView that is inherit from the UIView, and I want to do the layout in the Hello.xib, and I want to allocate them to the HelloView.m / HelloView.h, how can I do so? Thank you.
A:
In the interface builder's inspector for your Hello.xib's view, set the class of the view (in identity tab) to HelloView. I hope thats what you are looking for.
lukya
2010-08-18 06:58:10
+1
A:
You normally do so on the outside. In HelloView you should have a UIViewController derived class. Then when initializing it on the outside you would call:
hello = [[HelloViewController alloc] initWithNibName:@"Hello" bundle:nil];
The bundle:nil
make Cocoa use the default bundle.
DarkDust
2010-08-18 07:03:02
A:
Just today I wrote a demonstration code, that also uses instantiation of custom view by loading a nib
- the controller has a member
DetailContactHeaderView *headerView
- in the nib, I have a DetailContactHeaderView and the Files' owner type is my Controller
- the files' owner property
headerView
and the View get Connected in this controller I have this code
[[NSBundle mainBundle] loadNibNamed:@"DetailContactHeader" owner:self options:nil];
See my MyContacts for an implementation. FYI:
- DetailContactHeaderView
- DetailContactHeader.xib
- DetailContactViewController
- especially
-tableView:viewForHeaderInSection:
- especially
vikingosegundo
2010-08-18 07:23:07