IOS自定义UITableViewCell
来源:互联网 发布:mac显示隐藏文件快捷键 编辑:程序博客网 时间:2024/05/16 12:02
在用到UITableVIew的时候,经常会自定义每行的Cell
在IOS控件UITableView详解中的下面代码修改部分代码就可以实现自定义的Cell了
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
自定义代码:
static NSString *CellWithIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellWithIdentifier]; } NSUInteger row = [indexPath row]; // 自定义Cell中Image UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 24, 24, 24)]; imageView.image = [UIImage imageNamed:@"green.png"]; [cell.contentView addSubview:imageView]; [imageView release]; // 自定义文本信息 UILabel *city = [[UILabel alloc] initWithFrame:CGRectMake(50, 25, 100, 20)]; NSString *cityString = [[NSString alloc] initWithFormat:@"城市:%@",[self.dataList objectAtIndex:row]]; city.text = cityString; [cell.contentView addSubview:city]; [cityString release]; // cell.textLabel.text = [self.dataList objectAtIndex:row];// cell.imageView.image = [UIImage imageNamed:@"green.png"];// cell.detailTextLabel.text = @"详细信息";// cell.accessoryType = UITableViewCellSelectionStyleGray;
- iOS开发:自定义UITableViewCell
- iOS开发:自定义UITableViewCell
- IOS自定义UITableViewCell
- IOS 自定义UITableViewCell
- IOS自定义UITableViewCell
- ios 自定义tableViewcell,UITableViewCell
- IOS--自定义UITableViewCell
- iOS 自定义UITableViewCell
- iOS - 移动自定义UITableViewCell
- ios 自定义UiTableViewCell
- iOS开发15:自定义UITableViewCell
- ios控件 UITableViewCell的自定义
- iOS开发15:自定义UITableViewCell
- IOS学习之自定义UITableViewCell
- ios中代码自定义uitableviewcell
- ios中自定义cell,自定义UITableViewCell
- iOS开发笔记--自定义UITableViewCell
- IOS学习——自定义UITableViewCell
- Ext 布局(layout)
- 建立影像金字塔的意义
- 生活、工作、总结(一)
- 学习C++ primer的关键点记录一
- 有线 + hostapd 802.1X 认证
- IOS自定义UITableViewCell
- Android 2.3中ListView偶尔未正常通知已注册的OnScrollListener
- makefile -C
- ct1642串转并芯片驱动(网摘未改动篇)
- Objective-C基础教程一
- FLTK学习-2-新手入门参考
- 用等比数列解析伪列level的另一个作用
- arx记录,长期更新
- Android OpenGL基础教程 2