红桃J

用心写好每行完美的代码,远比写一堆更有价值

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

cell重用机制

http://blog.cnrainbird.com/index.php/2012/03/20/guan_yu_uitableview_de_cell_fu_yong_tan_tan_wo_de_yi_xie_xin_de/

实现tableView的连个代理<UITableViewDelegate, UITableViewDataSource>即可,然后实现这两个代理的两个必要方法:

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

这两个个方法,第一个是返回要显示的tableView中的cell的个数,第二个是为cell添加数据。其实根据cell的动态复用机制,就能推断出为cell添加数据的函数肯定是执行一次只能添加一个cell的。

 

 

posted on 2014-10-17 18:12  红桃J  阅读(129)  评论(0编辑  收藏  举报