UITableView

基本属性

   // 表单控件
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];

 // 设置表单的头部视图
    // tableView只有一个头视图和一个尾视图
    // 但是每个section都有一个头视图和尾视图
    UIImageView *headerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    headerView.backgroundColor = [UIColor redColor];
    tableView.tableHeaderView = headerView;

 tableView.separatorColor = [UIColor redColor];

  
    // 设置表单的头部视图
    // tableView只有一个头视图和一个尾视图
    // 但是每个section都有一个头视图和尾视图
    UIImageView *headerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    headerView.backgroundColor = [UIColor redColor];
    tableView.tableHeaderView = headerView;
    
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    footerView.backgroundColor = [UIColor blueColor];
    tableView.tableFooterView = footerView;

——————————————————————————————————————————————————————
datasource and delegate 
 表单视图中有多少个section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

——————————————————————————————————————————————————————
 某一个section的row数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

——————————————————————————————————————————————————————
某一个section的头视图标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

——————————————————————————————————————————————————————
某一个section的尾视图标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

——————————————————————————————————————————————————————
用于初始化特定位置的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

——————————————————————————————————————————————————————
section对应的index
Asks the data source to return the index of the section having the given title and section title index.
告诉数据源返回有给定标题和section标题的section的索引
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index

——————————————————————————————————————————————————————
Asks the data source to commit the insertion or deletion of a specified row in the receiver.
告诉数据源来提交在特定的行插入或者删除的操作
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

——————————————————————————————————————————————————————

Tells the data source to move a row at a specific location in the table view to another location. 
告诉数据源来移动一个行从一个指定的位置 到表单视图中的另一个位置
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
——————————————————————————————————————————————————————

// 选中行操作
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
——————————————————————————————————————————————————————
// 反选行操作 - 取消选中
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值