TableView基本使用
来源:互联网 发布:js判断map是否包含key 编辑:程序博客网 时间:2024/06/10 02:49
TableView基本使用
基本步奏
- 1设置数据源
self.tableview.dataSource = self;
- 2遵守协议
@interface ViewController () <UITableViewDataSource>@property (weak, nonatomic) IBOutlet UITableView *tableview;
- 3实现方法
有几组
每组有几行
每行设置什麽 内置了那些控件,自己点击command查找
/**
* 不是必须实现的方法
*
* @param tableView
*
* @return tabeleview多少分组
*/
“`objc
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
/** * 必须实现的方法 * * @param tableView * @param section * * @return 告诉tableview每个分组有多少行 */ ```objc- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0) { return 2; } else if (section == 1) { return 3; } else { return 4; }}
/**
* 对分组每行的内容进行设置
*
* @param tableView
* @param indexPath
*
* @return (UITableViewCell *)
*/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell * cell = [[UITableViewCell alloc] init]; if (indexPath.row == 0) { cell.textLabel.text = @"通用"; } else if(indexPath.row == 1) { cell.textLabel.text = @"隐私"; } else if (indexPath.row == 2) { cell.textLabel.text = @"必须"; } else { cell.textLabel.text = @"得更新"; } return cell;}
效果图:
出现的问题图:
0 0
- TableView的基本使用
- TableView基本使用
- tableView的基本使用
- iOS TableView的基本使用
- Swift学习之--TableView的基本使用
- OC - Masonry的基本使用(tableView作为实例)
- 基本控件使用(二)(ScrollView,TableView)
- TableView使用
- tableView的一些基本方法
- ios tableView基本属性一:
- iOS之tableView基本用法
- QT中tableview基本用法
- IOS 构造和使用TableView(基于storyboard) (一)基本的数据显示
- 如何使用TableView
- TableView的使用
- iphone tableView的使用
- Tableview的使用
- Iphone TableView 使用实现
- TCP建立连接为什么需要三次握手而结束要四次
- mac上配置redis集群方案--Codis的安装测试小结
- 【读书笔记】20150905Java编程那些事儿
- 从Hadoop到Spark的架构实践
- NDK开发之访问域
- TableView基本使用
- GDB调试ARM程序
- C语言基础学习——第8天(函数指针)
- LeetCode Roman to Integer
- 线性规划与网络流24题 01飞行员分配方案问题
- PAT Advanced 1019
- 线性规划与网络流24题 02太空飞行计划问题 最小割
- 漫谈C指针第六讲---从 const int i 说起
- 【Android进阶】-Android组合的方式自定义控件