【问题标题】:How to Subclass a UITableViewCell using the existing Xib file如何使用现有的 Xib 文件对 UITableViewCell 进行子类化
【发布时间】:2016-07-12 05:02:30
【问题描述】:

subclass 现有的 UITableViewCell 子类 的正确方法是什么,该子类具有附加的 Xib 文件。如何子类化 UITableViewCell 子类并在新类中仍然使用 Xib?

【问题讨论】:

    标签: ios objective-c uitableview ios8


    【解决方案1】:

    您需要做的就是使用相同的标识符,例如

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
         CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@“ExistingCellIdentifier"];
         if (cell == nil) {
              cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@“ExistingCellIdentifier"];
         }
    
         return cell;
    }
    

    希望对您有所帮助,如果您有任何问题,请提交,祝您好运。

    【讨论】:

      猜你喜欢
      • 2012-06-17
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-04
      • 2021-12-14
      相关资源
      最近更新 更多