Loading a Reusable UITableViewCell from a Nib

前端 未结 16 2218
遇见更好的自我
遇见更好的自我 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:22

    Louis method worked for me. This is the code I use to create the UITableViewCell from the nib:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {   
        UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCellId"];
    
        if (cell == nil) 
        {
            UIViewController *c = [[UIViewController alloc] initWithNibName:@"CustomCell" bundle:nil];
            cell = (PostCell *)c.view;
            [c release];
        }
    
        return cell;
    }
    

提交回复
热议问题