表视图(UITableView)的一些常用方法和属性:
一:常用属性:
1:@property(nonatomic) UITableViewCellSeparatorStyle separatorStyle; // 默认为UITableViewCellSeparatorStyleSingleLine
2:@property(nonatomic,retain) UIColor *separatorColor; // 默认为:the standard separator gray
3:@property(nonatomic,retain) UIView *tableHeaderView; // 头部视图
4:@property(nonatomic,retain) UIView *tableFooterView; // 尾部视图
5:@property(nonatomic) CGFloat rowHeight; // 单元格高度
6:@property(nonatomic) CGFloat sectionHeaderHeight; // 头部行高
7:@property(nonatomic) CGFloat sectionFooterHeight; // 尾部行高
8:@property(nonatomic,readwrite,retain) UIView *backgroundViewNS_AVAILABLE_IOS(3_2);
9:@property(nonatomic,readonly) UITableViewStyle style;
二:常用方法:
1:- (void)reloadData; // reloads everything from scratch. redisplays visible rows. because we only keep info about visible rows, this is cheap. will adjust offset if table shrinks 刷新单元格的数据
2:- (void)reloadSectionIndexTitlesNS_AVAILABLE_IOS(3_0); // reloads the index bar.
3:- (NSInteger)numberOfSections; //返回节的数量
4:- (NSInteger)numberOfRowsInSection:(NSInteger)section; //返回每个节的单元格的数量
5:- (CGRect)rectForSection:(NSInteger)section; // includes header, footer and all rows
6:- (CGRect)rectForHeaderInSection:(NSInteger)section;
7:- (CGRect)rectForFooterInSection:(NSInteger)section;
8:- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
9:- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point; // returns nil if point is outside table
10:- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell; //返回指定单元格的NSIndexPath实例
11:- (NSArray *)indexPathsForRowsInRect:(CGRect)rect; //返回指定范围的NSIndexPath实例数组
12:- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath; // returns nil if cell is not visible or index path is out of range //返回指定NSIndexPath实例的单元格实例
13:- (NSArray *)visibleCells; //返回可见的单元格的数组
14:- (NSArray *)indexPathsForVisibleRows; //返回可见单元格的NSIndexPath实例数组
15:- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)sectionNS_AVAILABLE_IOS(6_0);
16:- (UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)sectionNS_AVAILABLE_IOS(6_0);
17:- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated; //滑动到指定的位置,并且可以加上动画效果
18:- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;