UITableView基础语法
来源:互联网 发布:围巾淘宝加盟 编辑:程序博客网 时间:2024/06/05 22:52
UITableVIew
概述
继承自UIView,应用非常广泛,功能非常强大,是必须牢固掌握的重要控件用于显示多项内容(数据源)的列表可以垂直滚动,有索引基本样式,默认两种风格1.UITableViewStylePlain2.UITableViewSeyleGrouped结构头部视图(tableHeaderView)、尾部视图(tableFooterView),以及中间连续的单元格或section(分组样式下),而section也有头部视图(tableHeaderView)、尾部视图(tableFooterView)以及中间连续的单元格//以下两个数据源方法必须强制实现- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 20;}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"qyCell"; //检测、查询是否有闲置的单元格 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; } return cell;}
常用属性
UITableViewCell
NSIndexPath
浏览状态
设置表视图分割线风格@property(nonatomic) UITabelViewCellSeparatorStyle separatorStyle;设置表视图分割线颜色,默认标准灰色@property(nonatomic,retain) UIColor *separatroColor;设置表视图的头部视图@property(nonatomic,retain) UIView *tableHeaderView设置表示图的底部视图@property(nonatomic,retain) UIView *tableFooterView设置表示图单元格的行高@property(nonatomic)CGFloat rowHeight设置表视图section头部行高@property(nonatomic)CGFLoat sctionHeaderHeight设置表视图section底部行高@property(nonatomic)CGFloat sctionFooterHeight设置表视图背景@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默认为NO 当表视图在编辑时,单元格是否可以选中@property(nonatomic) allowsSelectionDuringEditing默认为NO 是否可以同时选中多个单元格,5.0以后才有@property(nonatomic) allowsMultipleSelection默认为No 在编辑状态下时 是否可以同时选中多个单元格 5.0以后才有@property(nonatomic) allowsMultipleSelectionDuringEditing
常用方法
浏览状态
指定一个cell 返回一个NsIndexPath实例 如果cell没有显示返回nil- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell指定一个范围 发挥一个数组 内容是NSIndexPath实例 指定的rect无效 返回 nil- (NSArray *)indexPathsForRowsInRect:(CGRect)rect指定一个NSIndexPath 发挥一个cell实例 如果cell没有显示返回nil- (UITableViewCell *)cellFroRowAtindexPath:(NSIndexPath *)indexPath根据显示的cell 返回一组cell实例的数组 如果没有显示 返回nil- (NSArray *)visibleCells根据显示的cell 发挥一组NSIndexPath实例的数组 若果没有显示 返回nil- (NSArray *)indexPathsForVisibleRows滑动到指定位置可以配置动画- (void)scrollToRowAtIndexPath:(NsIdexPath *)indexPath atScroolPosition:(UITableViewScrollPosition)scrollPosition animate:(BOOL)animated
编辑状态
插入一行cell 指定一个实现动画效果- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation删除一行- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation刷新一行- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation移动一行 5.0之后- (void)moveRowsAtIndexPath:(NSIndexPath *)indexPath toIndexPath(NSIndexPath *)
1 0
- UITableView基础语法
- UITableView基础
- UITableView基础
- UITableView基础
- UItableView基础加深
- IOS UITableView 基础应用
- UITableView(一)---- 基础
- UITableView基础(一)
- UI基础—UITableView
- iOS基础--UITableView,UITableViewController
- UITableView的基础部分
- UI基础-UITableView 编辑
- UI基础-UITableView 高级
- iOS开发基础 - UITableView
- UITableView 基础篇
- Swift UITableView基础
- UITableView使用基础篇
- UITableView基础 UITableView编辑,UITableViewCell自定义
- 游戏评测(随笔)
- ASCII码排序
- Codeforces Round #306 (Div. 2) A B C
- UILabel基础语法
- 生成n个元素的全排列 C实现
- UITableView基础语法
- gdb调试多线程
- 基于邻接表的图建立(有向图+无向图)
- xcode的使用技巧索引
- 不配置环境变量运行tomcat
- MyBatis学习总结(四)——解决字段名与实体类属性名不相同的冲突
- C# WPF Win7 标题栏添加按钮(模拟)
- UITextField基础语法
- Mac os x下,使用pip安装scrapy