iOS TableView 使用(swift)
2015-01-07 01:26
543 查看
1.Controller要实现UITableViewDelegate,UITableViewDataSource
class ViewController:UIViewController ,UITableViewDelegate,UITableViewDataSource
2.要将dataSource,delegate设置妥当
myTableView.dataSource =
self
myTableView.delegate =
self
3.完成delegate中的方法
//
func tableView(tableView:
UITableView, numberOfRowsInSection section:
Int) -> Int
{
return datas.count
}
//"cell"为TableViewCell的Identifier
func tableView(tableView:
UITableView, cellForRowAtIndexPath indexPath:
NSIndexPath) -> UITableViewCell
{
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell")
as
UITableViewCell
cell.textLabel?.text =
datas[indexPath.row]
return cell
}
class ViewController:UIViewController ,UITableViewDelegate,UITableViewDataSource
2.要将dataSource,delegate设置妥当
myTableView.dataSource =
self
myTableView.delegate =
self
3.完成delegate中的方法
//
func tableView(tableView:
UITableView, numberOfRowsInSection section:
Int) -> Int
{
return datas.count
}
//"cell"为TableViewCell的Identifier
func tableView(tableView:
UITableView, cellForRowAtIndexPath indexPath:
NSIndexPath) -> UITableViewCell
{
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell")
as
UITableViewCell
cell.textLabel?.text =
datas[indexPath.row]
return cell
}
相关文章推荐
- ios swift开发中,使用键盘,tableview根据键盘调整高度
- [ios开发基础之 Core Data[3]]如何使用NSFetchedResultsController 来集成TableView操作
- iOS学习之分段Table View的使用(Grouped样式表格)
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- IOS 构造和使用TableView(基于storyboard) (七)移动cell和section
- IOS 构造和使用TableView(基于storyboard) (三)附件的使用
- ios开发入门- tableview 简单使用(一)
- iOS开发 自定义tableView样式(使用代码/使用Interface Builder)、分组显示、给TableView增加索引、给TableView增加SearchBariOS开发 自定义tab
- IOS 只有在TableViewController里面才可以使用TableView的static cell
- IOS详解TableView——静态表格使用以及控制器间通讯
- IOS 构造和使用TableView(基于storyboard) (六)显示上下文菜单
- iOS学习之分段Table View的使用(Grouped样式表格)
- ios关于tableview重用机制的使用心得一
- IOS 构造和使用TableView(基于storyboard) (一)基本的数据显示
- iOS学习之分段Table View的使用(Grouped样式表格)
- iOS学习之Table View的简单使用
- IOS开发学习笔记(四)——使用TableView
- iOS开发笔记--TableView的详细使用
- IOS 构造和使用TableView(基于storyboard) (四)启用Table Viewcell的滑动删除
- IOS 构造和使用TableView(基于storyboard) (二)接收和处理Table View事件