UItableview以及UItableviewDelegate的简单使用
来源:互联网 发布:剑灵拳师捏脸数据 编辑:程序博客网 时间:2024/04/29 12:13
IOS中UItableview是一个比较重要的空间,也是在IOS学习中比较重要的一个控件,以此博客作为本人对tableview的学习笔记。
新建一个自己的控制器NewsViewController继承ViewController,同时勾选生成xib文件。
- 在xib文件中拖入一个UItableview
- 按住control键将xib里的UItableview拖拽到左边Placeholders栏中的File’s Ower
- 将UItableview拖拽到NewsViewController.m文件中作为成员变量并生成get和set方法
@interface NewsViewController () <UITableViewDelegate>@property (strong, nonatomic) IBOutlet UITableView *mTableView;@end
新建自己的Cell命名为NewsTableViewCell继承TableViewcell,并同时勾选生成xib文件。
- 在xib文件中托选自己要的控件到合适位置
- 在xib文件中按住control键拖拽到.m文件中生成相对应的get和set方法以及引用。
打开NewsViewController.m文件,设置NewsViewController为UItableview的代理。
在viewDidLoad方法中设置代理和数据源方法
self.mTableView.rowHeight = 84; //每个Cell的高度self.mTableView.delegate = self;self.mTableView.dataSource = self;
实现一下UITableViewDelegate的代理方法
/** * UITableViewDeleget必须实现的方法 * 每组的数据条数 * * @param tableView * @param section * * @return 每组的数据条数 */- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 8;}/** * UITableViewDeleget必须实现的方法 * * @param tableView * @param indexPath * * @return Cell */- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *ID = @"cell"; if (nib == nil) { nib = [UINib nibWithNibName:@"NewsTableViewCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:ID]; } NewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; return cell;}
0 0
- UItableview以及UItableviewDelegate的简单使用
- UITableView的简单使用
- UITableView的简单使用
- UITableView的简单使用
- UITableView的简单使用
- UITableView的简单使用
- UITableView的简单使用!
- UITableView的简单使用
- 关于UITableView的简单使用
- Swift UITableView 的简单使用
- 怎样创建表格---UITableView UITableViewDataSource UITableViewDelegate
- 怎样创建表格---UITableView UITableViewDataSource UITableViewDelegate .
- UITableView 应用(三)UITableViewDelegate 方法总结
- UITableViewDelegate的代理方法
- UICollectionView使用以及与UITableView的区别
- UITableViewDelegate
- UITableViewDelegate
- 表视图的简单使用-UITableView
- dede被注入页面 医院网站
- 织梦DedeCMS被挂马解决方案
- dede网站转移空间和数据库后后台验…
- dede后台点击无反应 dede网站…
- 你的 Docker 应用是安全的吗?
- UItableview以及UItableviewDelegate的简单使用
- 如何取消服务器/主机空间目录脚本…
- dede文章的数据库名是什么
- 织梦cms登录后台提示Function&nbsp…
- 织梦dedecms获取当前栏目路径及栏…
- DEDECMS修改文章TAG 给TAG加…
- Error page: / Err…
- Error page: /dede/logi…
- Error page: /dede/&nbs…