iPhone UITableView(利用UITableView实现平滑的九宫格效果)

 

UITableView是一种“目录视图或叫表视图”(英文名字table view),这种表视图以列表的形式显示或编辑信息,它由一列、多行组成。用户可以通过垂直滚动的方式导航到一个表视图的任意行上,并可以自定义每一行数据的显示方式。

 

在创建表视图的时候,可以选择两种风格的表视图:UITableViewStylePlain或者UITableViewStyleGrouped,前者是按索引进行排序的,而后者是按组进行分类显示的。

 

基本上每一个UITableView都有相应的UITableViewControllerUITableViewDelegateUITableViewDataSource类。UITableViewController类作为UITableView的视图控制类(MVCController的角色)负责管理UITableView,它和大多数UIViewController类一样,控制着UITableView的生命周期函数。UITableViewDelegate作为委托模式里的被委托对象的接口,和大多数iPhone委托接口一样,它提供了UITableView子类无法在行为上保持一致的部分,在这里读者可以自定义表视图的显示风格,甚至可以自定义表视图的每一个元素,它的重要接口定义如下:

 

@protocol UITableViewDelegate<NSObject, UIScrollViewDelegate>

@optional

 

// Display customization

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

 

// Variable height support

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

 

// Section header & footer information. Views are preferred over title should you decide to provide both

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; 

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;  

 

// Accessories (disclosures).

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;

 

// Selection

// Called before the user changes the selection. Return a new indexPat

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值