Is it possible to design NSCell subclasses in Interface Builder?

后端 未结 10 1278
终归单人心
终归单人心 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 15:40

    I want to provide a more modern approach here.

    Starting with iOS 5, UITableView has a method

    (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier

    Once you registered your NIB containing your cell, just use

    - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier

    to get a new cell. If a cell is available for reuse, it will be returned, otherwise a new cell is automatically created, and in that case this means loaded from the NIB file.

提交回复
热议问题