自定义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;
}
{
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;
}
相关文章推荐
- OC笔记 - xib封装view、Delegate、代码自定义高度不一致的cell(2015.2.15)
- 自定义xib tableviewcell 无法通过nsdata dataWithContentsOfFile读取的问题
- 通过xib和代码自定义cell
- 点击tableViewHeader控制cell关闭展开以及label的代码自定义约束
- 关于xib中要TableviewCell的自定义心得
- 自定义等高的cell(代码创建frame)
- cell的初始化方式(代码和xib)
- 给自定义cell赋值代码
- iOS 代码tableViewCell自适应label
- 纯代码自定义cell(cell高度不一致)
- IOS中xib+代码实现自定义cell中嵌套
- xib自定义cell之自适应高度
- (素材源码)猫猫学IOS(十六)UI之XIB自定义Cell实现团购UI
- swift 纯代码自定义cell(qq聊天界面)
- 通过代码自定义Cell
- 通过代码自定义cell(cell的高度不一致)
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(二)
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(三·完结)
- 第二十四篇:缩合练习代码---简单微博(自定义Cell)
- 自定义等高的cell(代码Autolayout)