随笔-UITableViewCell 自定义也没那么难
2015-04-01 16:57
169 查看
UITableViewCell 自定义也没那么难
运行结果:
#import "rootViewController.h" #import "myCell.h" - (void)viewDidLoad { [super viewDidLoad]; NSURL *plistURL = [[NSBundle mainBundle] URLForResource:@"about" withExtension:@"plist"]; allArray = [NSArray arrayWithContentsOfURL:plistURL]; NSLog(@"array====%@",allArray); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSLog(@"cccc"); return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"allarray count=== %d",[allArray count]); return [allArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"cell begin 1"); static NSString *mycell = @"cell"; myCell *cell = (myCell*)[tableView dequeueReusableCellWithIdentifier:mycell]; if (cell == nil) { NSArray *array = [[NSBundle mainBundle]loadNibNamed:@"myCell" owner:self options:nil]; cell = [array objectAtIndex:0]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; } NSDictionary *dic = [allArray objectAtIndex:[indexPath row]]; NSLog(@"*******%d",[indexPath row]); NSLog(@"dic === %@",dic); cell.imageView.image = [UIImage imageNamed:[dic objectForKey:@"image"]]; cell.name.text = [dic objectForKey:@"name"]; cell.infomation.text = [dic objectForKey:@"infomation"]; NSLog(@"nametext = %@",cell.name.text); cell.download.tag = [indexPath row]; [cell.download addTarget:self action:@selector(downBtnTap:) forControlEvents:UIControlEventTouchUpInside]; return cell; } -(void)downBtnTap:(id)sender { UIButton *btn=(UIButton *)sender; NSLog(@"下载 %d",btn.tag); } #pragma mark Table Delegate Methods - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 80; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"111111"); NSLog(@"didSelected ---- %d",[indexPath row]); }
运行结果:
相关文章推荐
- 如何使用xib自定义UITableViewCell
- MOSS 2007 应用随笔系列:自定义moss菜单汇总---转
- 用.xib文件自定义UITableViewCell
- IOS高访新浪微博界面(讲解如何自定义UITableViewCell,处理@#链接 特殊字符)
- 自定义UITableViewCell (通过代码实现:每个CELL格式不一样)
- 可任意自定义的UITableViewCell
- iOS纯代码自定义UITableViewCell及性能优化
- 安卓学习随笔 -- 自定义标题栏
- android 项目学习随笔十(自定义ProgressBar)
- 自定义UITableViewCell(二)
- PureCode--iOS--自定义UITableViewCell(含疑问)
- 自定义UITableViewCell上的delete按钮
- ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局
- uitableviewcell编辑模式自定义左边的图片按钮
- 对自定义UITableViewCell的理解
- 简单方法实现 uitableviewcell 左滑出现各种自定义功能视图
- iOS App开发中使用及自定义UITableViewCell的教程
- 两种使用自定义UITableViewCell的方法
- (七)-自定义UITableViewCell