OC开发_Storyboard——UITableView

 

一、tableView

1、datasource数据源

(1 构造每一个tableVIewCell的方法:cellForRowAtIndexPath,这里的

     dequeueReusableCellWithIdentifier会根据识别ID去取storyBoard中的cell,同时这也是利用取缓存中的cell复用

 

 (2 还包含了另外两个方法,numberOfSectionsInTableView 默认是返回1如果不重写它的话;numberOfRowsInSection是没有默认值的,所以实现数据源的时候这个是必须实现的

- (NSInteger)numberOfSectionsInTableView:(UITableView *)sender; 

- (NSInteger)tableView:(UITableView *)sender numberOfRowsInSection:(NSInteger)section;

 

2、delegate 协议,方法有很多,这里仅仅举例两个

 (1 比如用户点了哪一行?做了什么操作?

   - (void)tableView:(UITableView *)sender didSelectRowAtIndexPath:(NSIndexPath *)path

 (2  每个cell的图标的点击如下图:

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

 

3、segue 点击cell跳转的时候,

    比如跳转到另外一个segue,那么对应的 prepareForSegue就应该知道是哪一个cell的点击,所以sender参数就起到了这个作用

   我们可以利用 NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];

 

4、加载中的spinner

    @property (strong) UIRefreshControl *refreshControl;

    开启加载动画: - (void)beginRefreshing;

    结束加载动画:- (void)endRefreshing;

 当然需要启动配置:

       

5、reloadData重新加载数据

  - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths  withRowAnimation:(UITableViewRowAnimation)animationStyle;

详情的tableView方法可以参考之前写的这篇文章:http://www.cnblogs.com/daomul/p/4370128.html

 

posted @ 2015-05-03 11:03  daomul  阅读(615)  评论(0编辑  收藏  举报