表视图 TableView 的使用
来源:互联网 发布:java 弱引用 使用场景 编辑:程序博客网 时间:2024/06/07 00:45
1、新建接口 TableViewCell ,用于显示单元格的内容
@interface RegionTableViewCell : UITableViewCell@property (strong, nonatomic) IBOutlet UILabel *regionName;@property (strong, nonatomic) IBOutlet UIImageView *regionImage;@end
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { // Initialization code } return self;}- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state}2、新建 TableViewController ,作为 TableView 的控制器,并实现下面三个接口
// 返回分段数量- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1;}
// 返回对应分段的记录数量,即有多少行数据- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return self.arrRegionData.count;}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// 获得一个单元格
// 对单元格进行配置
}
每个返回的cell类型
4、UITableViewCell
设置单元格的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
// 单元格发生触碰- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{}- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; // 获得跳转时触碰的单元格索引路径}
0 0
- TableView表视图的使用
- 表视图 TableView 的使用
- 表视图tableView的使用---摘自培训文档
- tableView的使用(二)当前tableView视图中添加一行cell
- tableView 头视图的高度
- 取消TableView的头尾视图
- 单视图,多TableView的处理思路
- UI tableView 的头视图 & "小广告"
- tableview组的尾视图高度
- TableView的使用
- iphone tableView的使用
- Tableview的使用
- 简单tableView的使用
- ios tableView 的使用
- TableView的基本使用
- TableView的详细使用
- COCOS2DX - TableView的使用
- swift- tableView 的使用
- poj 3292 筛4n+1素数
- showModalDialog使用详解(IE4+ 支持)
- AFJSONRequestSerializer
- Shell: /dev/null 2>&1详解
- DNS服务及基于BIND的实现
- 表视图 TableView 的使用
- java中堆和堆栈的区别及实例
- 验证码的功能实现
- Android UI 之一步步教你自定义控件
- Climbing Stairs
- java集群优化——ORM框架查询优化原理
- ActionBarActivity xml设置无标题 出现 java.lang.illegalStateException : you need to use a theme.appCompat
- ORACLE数据库使用PL/SQL一闪而过问题的解决方法
- 应用程序间通信