iOS tableview的过程
1、h文件 声明
viewcontroller <UITableViewDataSource,UITableViewDelegate>
2、m文件 设置代理
self.tableView.delegate=self;
self.tableView.dataSource=self;
3、m文件 实现必须的方法
//返回多少行cell
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
//返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
4、非必需
//点击cell触发
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
//设置cell高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

本文详细介绍了iOS中TableView的使用过程,包括.h文件中代理角色声明、.m文件中代理及数据源的设置、必须实现的方法如返回cell数量及cell本身等。此外还涉及了非必须实现的方法介绍。
2592

被折叠的 条评论
为什么被折叠?



