Xcode 4: Creating a UIView xib, not properly connecting

前端 未结 30 3464
时光说笑
时光说笑 2020-12-02 16:29

I\'m trying to create a nib that contains a view that will be embedded in a TableViewCell. I\'ve created the interface and implementation files, ResultCell.h an

30条回答
  •  隐瞒了意图╮
    2020-12-02 16:47

    1. ResultCell should be a subclass of UITableViewCell
    2. You should not drag a UIView onto the empty canvas, you should drag a UITableViewCell
    3. You should select the cell and change it to be your subclass
    4. The owner is most often a controller with an outlet to the cell

    Everytime you want to load a new cell, call:

     [[NSBundle mainBundle] loadNibNamed:nibName 
                                   owner:controllerWithOutletToCell 
                                 options:nil]
    

    after loading, use the cell, and set the ivar/outlet to nil, ready for the next load

    there are other ways, but this is common

提交回复
热议问题