views:

42

answers:

1

What am I doing wrong here?

Created:

CustomTab.h

#import <UIKit/UIKit.h>

@interface CustomTab : UIView {
 IBOutlet UIView *view;
}

@property (nonatomic, retain) IBOutlet UIView *view;

@end

CustomTab.m

#import "CustomTab.h"
@implementation CustomTab    
@synthesize view;

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Initialization code
    }
    return self;
}

- (void)dealloc {
    [super dealloc];
}
@end
  • XIB file set its files owner to be CustomTab's class, hooked up the view

In my UIViewController class

- (void)viewDidLoad {

   [super viewDidLoad];   

   CGRect frame = CGRectMake(0, 0, 320, 40); // Replacing with your dimensions 
   CustomTab *myObj = [[CustomTab alloc] initWithFrame:frame];

   [self.view addSubview:myObj.view];
   [myObj release];
}

The subview doesnt appear on the screen. What am I missing?

+2  A: 

The nib file does not bind itself to your UIView automatically. If your view is owner, I guess you can use loadNibNamed:owner: of NSBundle interface to load your view after your have init your view.

tia