Subclass of UIView with Xib file.
Posted
by rdesign
on Stack Overflow
See other posts from Stack Overflow
or by rdesign
Published on 2010-04-16T06:39:18Z
Indexed on
2010/04/16
6:43 UTC
Read the original article
Hit count: 376
Hey guys,
Although I've searched the Board and used google, I didn't get any useful results. I've trying to make a subclass of UIView loading its view from a xib file.
My approach is the following: 1. Creating a subclass (named mySubclass):
@interface mySubclass : UIView {
}
@end
Creating a view through: Add New File... User Interface View XIB
Connecting the Xib and the subclass: In IB select the View and set the class to mySubclass.
In my viewController I make an instance of my new subclass and add to my view.
-(void)viewDidLoad {
mySubclassIns = [[mySubclass alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; [self.view addSubview:mySubclassIns];
[super viewDidLoad]; }
Result:
Noting shows up in my App :( If I don't set it up programmatically but rather with IB it doesn't work either. (Am I setting it up right when choosing a view in IB and set the class to myClass?)
I would be really thankful for your help!
Thanks in advance.
© Stack Overflow or respective owner