Loading a Reusable UITableViewCell from a Nib

前端 未结 16 2281
遇见更好的自我
遇见更好的自我 2020-11-27 09:59

I am able to design custom UITableViewCells and load them just fine using the technique described in the thread found at http://forums.macrumors.com/showthread.php?t=545061.

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 10:15

    Here is another option:

    NSString * cellId = @"reuseCell";  
    //...
    NSArray * nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomTableCell" owner:nil options:nil];
    
    for (id obj in nibObjects)
    {
        if ([obj isKindOfClass:[CustomTableCell class]])
        {
            cell = obj;
            [cell setValue:cellId forKey:@"reuseIdentifier"];
            break;
        }
    }
    

提交回复
热议问题