Is it possible to design NSCell subclasses in Interface Builder?

后端 未结 10 1254
终归单人心
终归单人心 2020-12-13 15:09

I\'m trying to subclass NSCell for use in a NSTableView. The cell I want to create is fairly complicated so it would be very useful if I could design it in Interface Builder

10条回答
  •  离开以前
    2020-12-13 15:43

    Add your UITableViewCell to your tableviewcontroller and declare an IBOutlet property:

    @interface KuguTableViewController : UITableViewController {
        IBOutlet UITableViewCell *customTypeCell;
    }
    
    @property (readonly)  UITableViewCell *customTypeCell;
    

    ... then in cellForRowAtIndexPath you can just use your cell and set it to be reused:

    static NSString *CellIdentifier = @"CustomCell"
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
            cell = customTypeCell;
            cell.reuseIdentifier = CellIdentifier;
    

提交回复
热议问题