Instantiate view on iOS with mix of XIB and View class

How avoided storyboard and overloading XIB with just right split between what is visually defined and what is programatically programmed:

  1. visual set-up of the view in Interface builder – only view, no controllers and setting up outlets but no actions. AddNoteView.xib . Justify controls, set up autoscaling etc..
  2. create AddNoteView.h with outlets
  3. create AddNoteView.m and hook awakeFromNib and setup additional settings on view- (void)awakeFromNib{

    [super awakeFromNib];

    CALayer * layer = [self.locationThumb layer];

    [layer setMasksToBounds:YES];

    [layer setCornerRadius:10.0];

  4. create AddNoteViewController.m and define loadView- (void)loadView {

    self.view =  [[UINib nibWithNibName:@”AddNoteView” bundle:nil]  instantiateWithOwner:nil options:nil][0];

    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.