01-UI基础-04-02-UITableView : UIScrollView

##继承关系 Inherits From


##简介 An instance of UITableView (or simply, a table view) is a means for displaying and editing hierarchical lists of information.

UITableView的实例(或者只是表视图)是一个用于显示和编辑的分层列表信息。

初始化一个UITableView对象

- (instancetype)initWithFrame:(CGRect)frame  style:(UITableViewStyle)style
// UITableViewStyle的定义:
typedef enum {
   UITableViewStylePlain,//一个普通的表视图。任何一节表头和表尾显示为内联分隔符和浮动当滚动表格视图。
   UITableViewStyleGrouped // 部分的表视图呈现截然不同的分组里面
} UITableViewStyle;

##常用方法和属性

配置图表参数

@property(nonatomic, readonly) UITableViewStyle style;
style Property;
// 每一组有多少行数据
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
// 当前tableView里有多少section,默认为1 
numberOfSections Property
// 行高 
rowHeight Property
// 分隔线属性 
separatorStyle Property
separatorColor Property
separatorEffect Property
// tableview的背景 
backgroundView Property
separatorInset Property
cellLayoutMarginsFollowReadableWidth Property

创建单元格

- registerNib:forCellReuseIdentifier:
- registerClass:forCellReuseIdentifier:
- dequeueReusableCellWithIdentifier:forIndexPath:
- dequeueReusableCellWithIdentifier:

设置表头和表尾

- registerNib:forHeaderFooterViewReuseIdentifier:
- registerClass:forHeaderFooterViewReuseIdentifier:
- dequeueReusableHeaderFooterViewWithIdentifier:
tableHeaderView Property
tableFooterView Property
sectionHeaderHeight Property
sectionFooterHeight Property
- headerViewForSection:
- footerViewForSection:

设置单元格和Sections

// 每一行显示什么内容
//每当有一个cell进入视野屏幕就会调用,所以在这个方法内部就需要优化。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(cell==nil){
	 //在这里面做创建的工作。循环优化。防止刷新cell进入屏幕的时候重复的创建
    } 
}
//当调用reloadData的时候,会重新刷新调用数据源内所有方法,其他事情都不会做呀
 [self reloadData]
 
- indexPathForCell:
- indexPathForRowAtPoint:
- indexPathsForRowsInRect:
visibleCells Property
indexPathsForVisibleRows Property

估计元素高度

estimatedRowHeight Property
estimatedSectionHeaderHeight Property
estimatedSectionFooterHeight Property

滚动表视图

- scrollToRowAtIndexPath:atScrollPosition:animated:
- scrollToNearestSelectedRowAtScrollPosition:animated:

管理选择

indexPathForSelectedRow Property
indexPathsForSelectedRows Property
- selectRowAtIndexPath:animated:scrollPosition:
- deselectRowAtIndexPath:animated:
allowsSelection Property
allowsMultipleSelection Property
allowsSelectionDuringEditing Property
allowsMultipleSelectionDuringEditing Property

插入、删除、移动单元格和Sections

- beginUpdates
- endUpdates
- insertRowsAtIndexPaths:withRowAnimation:
- deleteRowsAtIndexPaths:withRowAnimation:
- moveRowAtIndexPath:toIndexPath:
- insertSections:withRowAnimation:
- deleteSections:withRowAnimation:
- moveSection:toSection:

单元格编辑

editing Property
- setEditing:animated:

重载表视图

- reloadData
- reloadRowsAtIndexPaths:withRowAnimation:
- reloadSections:withRowAnimation:
- reloadSectionIndexTitles

访问的表视图区域

- rectForSection:
- rectForRowAtIndexPath:
- rectForFooterInSection:
- rectForHeaderInSection:

delegate和数据源

// dataSource Property
@property(nonatomic, weak) id< UITableViewDataSource > dataSource;
// delegate Property
@property(nonatomic, weak) id< UITableViewDelegate > delegate;

UITableViewDelegate UITableViewDataSource

配置表索引

sectionIndexMinimumDisplayRowCount Property
sectionIndexColor Property
sectionIndexBackgroundColor Property
sectionIndexTrackingBackgroundColor Property

管理焦点

remembersLastFocusedIndexPath Property

常量

UITableViewStyle
UITableViewScrollPosition
UITableViewRowAnimation
Section Index Icons
Default Dimension

##通知

UITableViewSelectionDidChangeNotification
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值