表格视图 - 使用代码自定义行高度
2015-12-17 11:20
555 查看
1. 实现UITableViewDelegate协议
@interface ViewController () <UITableViewDelegate>
2. 将表格视图的代理属性指向其父容器视图
self.myTableView.delegate = self;
3. 实现协议对应的方法
tableView:heightForRowAtIndexPath:
完整代码(ViewController.m):
@interface ViewController () <UITableViewDelegate>
2. 将表格视图的代理属性指向其父容器视图
self.myTableView.delegate = self;
3. 实现协议对应的方法
tableView:heightForRowAtIndexPath:
完整代码(ViewController.m):
#import "ViewController.h" @interface ViewController () <UITableViewDelegate> @property (nonatomic, strong) UITableView *myTableView; @end @implementation ViewController - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if ([tableView isEqual:self.myTableView]){ return 100.0f; } return 40.0f; } - (void)viewDidLoad{ [super viewDidLoad]; self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; self.myTableView.delegate = self; [self.view addSubview:self.myTableView]; } @end
相关文章推荐
- python中的参数
- checkbox 全选反选实现全代码
- 去掉java中的注释(尤其针对反编译后的文件)
- WebService学习笔记(三)wsdl2java代码生成
- java资料——线性表(转)
- Spring 配置log4j和简单介绍Log4J的使用
- java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opene
- RxJava随记
- MyEclipse 怎样手动编译整个项目
- Spring jdbctemplate学习笔记
- spring运用DBCP连接数据源
- Java设计模式圣经连载(05)-代理模式
- C#当中的多线程_任务并行库(上)
- 如何在Android Studio中导入eclipse的library project
- Php官方指导安装与配置
- Qt4.8.5下 Qtserialport 安装中找不到cfgmgr32.h的解决
- C语言结构体初始化的三种方法
- Java代码书写规范示例
- [译]详解C++右值引用
- Python计算文件MD5值