最近开发UITableView调用自定义的UITableViewCell的方式适用于低版本
来源:互联网 发布:et网络运动会管理系统 编辑:程序博客网 时间:2024/06/08 14:36
下面的内容主要:
当自定义了一个UITableViewCell后,如何加载的问题。最好适用于低版本,这个代码适用于低版本的解决办法,之前
的办法只能适用于ios5以上版本。但是下面的代码能够适应低版本问题。
这个是再主TableView的类中的,调用cellForRowAtIndexPath,加载每一行的数据内容。每一行都是一个UITableViewCell
主要参考了这篇http://blog.csdn.net/xiaoquanhuang/article/details/6856688文章来实现我的功能。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
DiscountProductCell * cell= (DiscountProductCell*)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
if (cell == nil) {
NSArray * nib = [[NSBundle mainBundle] loadNibNamed:@"DiscountProductCell" owner:self options:nil] ;
cell = [nib objectAtIndex:0];
}
PushItm * mPushItem = [mPushItems objectAtIndex:indexPath.row];
NSLog(@"mPushItem 放在了加载cell里面:%@",mPushItem);
NSLog(@"mPushItem.type-%d",mPushItem.type);
NSLog(@"mPushItem.desc-%@",mPushItem.desc);
NSLog(@"mPushItem.isRead-%@",mPushItem.isRead?@"YES":@"NO");
NSLog(@"mPushItem.itemId-%@",mPushItem.itemId);
NSLog(@"mPushItem.title-%@",mPushItem.title);
http://blog.csdn.net/xiaoquanhuang/article/details/6856688
cell.item = mPushItem;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list"]] autorelease];
cell.backgroundView = backgroundView;
UIImageView *accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ad1"]] autorelease];
[accessoryView setFrame:CGRectMake(0.0f, 0.0f, CATEGORY_CELL_AC_WIDTH, CATEGORY_CELL_AC_HEIGHT)];
cell.accessoryView = accessoryView;
return cell;
}
- 最近开发UITableView调用自定义的UITableViewCell的方式适用于低版本
- Swift中UITableView的用法(自定义UITableView和UITableViewCell)
- 使用自定义的tableViewCell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
- 使用UITableView的自定义UITableViewCell构建聊天界面
- iOS之UITableView的使用——自定义UITableViewCell
- 自定义UITableViewCell的两种方式
- IOS开发中UITableView和UITableViewCell的几种样式
- iOS开发中UITableView和UITableViewCell的几种样式
- IOS开发中UITableView和UITableViewCell的几种样式
- IOS开发中UITableView和UITableViewCell的几种样式
- IOS开发中UITableView和UITableViewCell的几种样式
- IOS开发中UITableView和UITableViewCell的几种样式
- iOS开发中UITableView和UItableViewCell的几种形式
- iOS开发中UITableView和UITableViewCell的几种样式
- iOS开发中UITableView和UITableViewCell的几种样式
- iOS开发中UITableView和UITableViewCell的几种样式
- iOS开发中UITableView和UITableViewCell的几种样式
- UITableView与UITableViewCell的使用
- [centos6.2] 文本安装后安装桌面环境
- getCanonicalName getSimpleName getName 区别与应用
- Android ApiDemos示例解析(46):App->Voice Recognition
- UART串口通信
- Eclipse快捷键
- 最近开发UITableView调用自定义的UITableViewCell的方式适用于低版本
- C++ - 汉诺塔
- ACM竞赛之新人向导 (鉴于这么多人问如何自学)
- 构造解数独
- UVa 10562 - Undraw the Trees (不限制儿子个数的树)
- 和菜鸟一起学证券投资之股市常见概念公式2
- 2_在Linux环境下面_HTTPD的安装
- 建立逻辑standby
- FusionCharts_free网页图标工具包