首页 技术 正文
技术 2022年11月8日
0 收藏 764 点赞 1,801 浏览 1133 个字

一、tableView

1、datasource数据源

(1 构造每一个tableVIewCell的方法:cellForRowAtIndexPath,这里的

dequeueReusableCellWithIdentifier会根据识别ID去取storyBoard中的cell,同时这也是利用取缓存中的cell复用

OC开发_Storyboard——UITableView

(2 还包含了另外两个方法,numberOfSectionsInTableView 默认是返回1如果不重写它的话;numberOfRowsInSection是没有默认值的,所以实现数据源的时候这个是必须实现的

– (NSInteger)numberOfSectionsInTableView:(UITableView *)sender;

– (NSInteger)tableView:(UITableView *)sender numberOfRowsInSection:(NSInteger)section;

2、delegate 协议,方法有很多,这里仅仅举例两个

(1 比如用户点了哪一行?做了什么操作?

– (void)tableView:(UITableView *)sender didSelectRowAtIndexPath:(NSIndexPath *)path

(2  每个cell的图标的点击如下图:

– (void)tableView:(UITableView *)sender accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath         OC开发_Storyboard——UITableView

3、segue 点击cell跳转的时候,

比如跳转到另外一个segue,那么对应的 prepareForSegue就应该知道是哪一个cell的点击,所以sender参数就起到了这个作用

我们可以利用 NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];

OC开发_Storyboard——UITableView

4、加载中的spinner

@property (strong) UIRefreshControl *refreshControl;

开启加载动画: – (void)beginRefreshing;

结束加载动画:- (void)endRefreshing;

当然需要启动配置:

OC开发_Storyboard——UITableView

5、reloadData重新加载数据

– (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths  withRowAnimation:(UITableViewRowAnimation)animationStyle;

详情的tableView方法可以参考之前写的这篇文章:http://www.cnblogs.com/daomul/p/4370128.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905