I\'m familiar with most of the process of creating an XIB for my own UIView subclass, but not everything is working properly for me - it\'s mostly to do with the IBOutlets l
Here's one method that I use:
UIView
, this will be called MyClass
ParentViewController
.MyClass
.MyClass
will be
connected by click-dragging from View (not File's Owner). If you want to connect them to variables from ParentViewController
then click-drag from File's Owner.ParentViewController
you need to declare an instance
variable for MyClass
.ParentViewController.h
add the following:
@class MyClass
@interface ParentViewController : UIViewController {
MyClass *myClass;
}
@property (strong, nonatomic) MyClass *myClass;
Synthesize this in your implementation and add the following in your
viewDidLoad
method:
- (void)viewDidLoad {
[super viewDidLoad];
[[NSBundle mainBundle] loadNibNamed:@"MyClass" owner:self options:nil];
self.myClass.frame = CGRectMake(X,Y,W,H); //put your values in.
[self.view addSubview:self.myClass];
}