自定义UITableViewCell
2016-02-24 00:00
405 查看
1、创建xib
2、创建一个继承UITableViewCell的控制器
3、xib和控制器绑定起来。
4、用 NSBundle加载
5、设置自适应高度。
最后前面别忘记引入UITableViewDataSourceDelegate和UITableViewDelegate 并设置代理
2、创建一个继承UITableViewCell的控制器
3、xib和控制器绑定起来。
4、用 NSBundle加载
5、设置自适应高度。
#pragma mark 多少条 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 6; } #pragma mark 加载cell -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellID=@"blogcell"; UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:cellID]; if (cell==nil) { cell=[[[NSBundle mainBundle]loadNibNamed:@"BlogCell" owner:self options:nil] lastObject]; } UILabel * label=[cell viewWithTag:2]; label.text=@"大灰狼"; return cell; } #pragma mark 自适应高度 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [self tableView:_tableView cellForRowAtIndexPath:indexPath]; return cell.frame.size.height; }
最后前面别忘记引入UITableViewDataSourceDelegate和UITableViewDelegate 并设置代理
相关文章推荐
- 栈与queue
- 快速排序QuickSort
- 如何修改UIButton的imageView显示以及裁剪图片
- 基于UGUI 的 游戏UI框架的一些想法
- POJ--3481 Double Queue
- easy ui grid的简单应用
- 动态树(LCT):HDU 4010 Query on The Trees
- Failed to convert value of type...no matching editors or conversion strategy found
- UIColectionView实现无限滚动(图片轮播)
- ios-UI控件精讲之【3】-UIWindow
- mybaties注解requestParam("id") String[] ids
- UIView基础笔记
- RabbitMQ Exchange & Queue Design Trade-off
- LeetCode-304. Range Sum Query 2D - Immutable
- [Locked] Verify Preorder Sequence in Binary Search Tree
- 使用phantomjs进行无界面UI自动化测试
- sequence有关问题
- hdu3530Subsequence【单调队列优化dp】2010多校联合
- 334. Increasing Triplet Subsequence【M】【69】
- STL_queue