您的位置:首页 > 编程语言

自定义xib TableViewCell 标准写法 代码段

2013-11-13 11:25 423 查看
+ (CustonCell *)cellFromNibNamed:(NSString *)nibName
{
    NSArray *nibContents = [[NSBundlemainBundle]
loadNibNamed:nibName owner:self
options:NULL];
    NSEnumerator *nibEnumerator = [nibContentsobjectEnumerator];
    KIPullToRevealCell *customCell =
nil;
    NSObject* nibItem = nil;
    while ((nibItem = [nibEnumerator
nextObject]) != nil)
    {
        if ([nibItem isKindOfClass:[KIPullToRevealCellclass]])
        {
            customCell = (CustonCell *)nibItem;
            break;
        }
    }
    return customCell;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *stCellIdentifier =@"Cell";
    CustonCell *cell = (CustonCell *)[tableViewdequeueReusableCellWithIdentifier:stCellIdentifier];
    
    if(!cell)
        cell = (CustonCell *)[CustonCellcellFromNibNamed:NSStringFromClass([CustonCellclass])];

    
    return cell;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  自定义 cell