CS193p Lecture 11 - UITableView, iPad

UITableView 的 dataSource 和 delegate

 

dataSource 是一种协议,由 UITableView 实现,将 Model 的数据给到 UITableView;

delegate 是关于表格是如何显示的,比如:

 - 如何排布元素;

 - 用哪些视图显示header、footer;

 - 如果用户点击某行,如何响应;

 

dataSource

 - numberOfSectionsInTableView

 - numberOfRowsInSection

 - cellForRowAtIndexPath

  create a cell

1 static NSString *cellIdentifier = @"myCell";
2 
3 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
4 
5 if (cell == nil) {
6     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
7     
8     // 配置cell中元素的属性
9 }

 

delegate

 - willDisplayCell

 - didEndDisplayingCell

 - heightForRowAtIndexPath

 - willSelectRowAtIndexPath

 - didSelectRowAtIndexPath

 

UITableView Spinner(网络加载中那个转圈圈)

属性:refreshControl

beginRefreshing

endRefreshing

 

reloadData

会重载整个表格

reloadRowsAtIndexPath

重载指定行

 

 

iPad的特别之处在于,屏幕大,因此有些手机上需要segue到新页面,在iPad上不用

 

posted @ 2015-06-14 00:41  mobilefeng  阅读(177)  评论(0编辑  收藏  举报