So, I was looking for using UITableView's registerNib: and [dequeueReusableCellWithIdentifier: forIndexPath:] to load a custom UITableCellView from the NIB . Here are the important bits of my controller:
- (void)viewDidLoad [super viewDidLoad]; self.tableView.bounces = NO; [self.tableView registerNib:[UINib nibWithNibName:@"ProgramListViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"]; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath TVProgramListTableViewCell *cell = (TVProgramListTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; cell.frame = CGRectMake(0, 0, CELLWIDTH, OPENCELLHEIGHT); cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.clipsToBounds = YES; cell.titleLabel.text = [NSString stringWithFormat:@"herpa derp: %i", indexPath.row]; return cell;
So, I register the NIB when loading the view, and then using it to de-synchronize the cell. Up to this point, everything works as I expect. My custom TVProgramListTableViewCell loads correctly from the NIB and it connects IBOutlet .
NIB contains a view with a button in it that I would like to have fire events for the controller. I can set the File Owner type as the Table View Controller class, but I donβt know how to actually connect the File Owner.
Now, if I used loadNibNamed: and downloaded NIB myself, connecting to the file owner would be easy. Is there a way to achieve this using registerNib ? Besides being unable to attach a File Owner, this seems like the perfect way to use custom cells in a UITableView .
Ville rinne
source share