Reputation: 8070
I added a custom view class with its own xib. In the xib, File's Owner -> Custom Class is set to "MyCustomView".
I added a blank view in my storyboard with class set to "MyCustomView"
When I run my app, I don't see my view being displayed properly. However, I do see 2013-03-01 16:52:48.283 Test[56785:c07] MyCustomView initWithCoder
Any ideas what went wrong?
I have isolated this error here: http://bit.ly/YdDbqU
Thanks!
EDIT:
I used the following:
UIView *subview = [[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil].lastObject; subview.frame = self.myCustomViewInstance.bounds; [self.view addSubview:subview];
Any everything worked!
Upvotes: 0
Views: 475
Reputation: 1192
Make sure your class is a inherits from UIViewController.
@interface ClassName : UIViewController
Upvotes: 0
Reputation: 8070
I used the following:
UIView *subview = [[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil].lastObject; subview.frame = self.myCustomViewInstance.bounds; [self.view addSubview:subview];
Any everything worked!
Upvotes: 0
Reputation: 104092
You never actually load that xib -- setting the class in IB isn't enough. You still need to load the xib file, and set your controller's view to that view;
#import "FirstViewController.h"
#import "MyCustomView.h"
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view = [[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil].lastObject;
}
Upvotes: 1