0
votes

I have a UITableViewController subclass that I want to use in conjunction with storyboards in order to set a custom background view. My subclass overrides the init method like so:

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.tableView.backgroundColor = [UIColor clearColor];
        self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:iPhone568ImageNamed(@"background.png")]];
    }
    return self;
}

Now when I try and instantiate a new tableview controller (this is interface definition):

@interface AVSelectTableViewController : AVCustomTableViewController

The init method is crashing on any call to self.tableView. Everything looks connected in storyboard (table datasource and delegate points to AVSelectTableViewController parent).

Reading the docs it appears that perhaps the tableView property isn't being set correctly (it just returns the tableview managed by a controller); however I'm not sure how to access it. Any thoughts?

1

1 Answers

3
votes

Use awakeFromNib instead of initWithCoder