表视图常用属性和方法

来源:互联网 发布:win10好软件 编辑:程序博客网 时间:2024/06/06 20:26
表视图常用属性和方法




// 设置表视图分割线风格
@property(nonatomic) UITableViewCellSeparatorStyle separatorStyle;


// 设置表视图分割线颜色,默认标准灰色
@property(nonatomic,retain) UIColor *separatorColor;


// 设置表视图的头部视图
@property(nonatomic,retain) UIView *tableHeaderView;


// 设置表视图的尾部视图
@property(nonatomic,retain) UIView *tableFooterView;


// 设置表视图单元格的行高
@property(nonatomic) CGFloat rowHeight;


// 设置表视图section头部行高
@property(nonatomic) CGFloat sectionHeaderHeight;


// 设置表视图section头部行高
@property(nonatomic) CGFloat sectionFooterHeight;


// 设置表视图背景
@property(nonatomic, readwrite, retain) UIView *backgroundView


// 刷新表视图单元格中数据
- (void)reloadData;


// 刷新表视图section中数据
- (void)reloadSectionIndexTitles




// 默认为NO,不可以编辑,设置时,不存在动画效果
@property(nonatomic,getter=isEditing) BOOL editing;


// 覆盖此方法,存在动画效果
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;


// 默认为YES,当表视图不在编辑时,单元格是否可以选中
@property(nonatomic) BOOL allowsSelection NS_AVAILABLE_IOS(3_0);


// 默认为NO,当表视图在编辑时,单元格是否可以选中
@property(nonatomic) BOOL allowsSelectionDuringEditing;


// 默认为NO,是否可以同时选中多个单元格,注意版本问题
@property(nonatomic) BOOL allowsMultipleSelection NS_AVAILABLE_IOS(5_0);


// 默认为NO,在编辑状态下时,是否可以同时选中多个单元格,注意版本问题
@property(nonatomic) BOOL allowsMultipleSelectionDuringEditing  NS_AVAILABLE_IOS(5_0);








常用方法


// 指定一个cell,返回一个NSIndexPath实例,如果cell没有显示,返回nil
- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell;


// 指定一个范围,返回一个数组,内容是NSIndexPath实例,指定rect无效,返回nil
- (NSArray *)indexPathsForRowsInRect:(CGRect)rect;


// 指定一个NSIndexPath,返回一个cell实例,如果cell没有显示,返回为nil
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;


// 根据显示的cell,返回一组cell实例的数组,如果没有显示,返回nil
- (NSArray *)visibleCells;


// 根据显示的cell,返回一组NSIndexPath实例的数组,如果没有显示,返回nil
- (NSArray *)indexPathsForVisibleRows;


// 滑动到指定的位置,可以配置动画
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;


// 插入一行cell,指定一个实现动画效果
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;


// 删除一行cell, 指定一个实现动画效果
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;


// 刷新一个行cell,指定一个实现动画效果
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);


// 移动cell的位置,指定一个实现动画效果
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath*)newIndexPath NS_AVAILABLE_IOS(5_0);





0 0
原创粉丝点击