您的位置:首页 > 其它

使用TableView

2015-04-26 20:46 183 查看
关键代码如下:

import UIKit

class MyTV: UITableView ,UITableViewDataSource{

let table_cell=1

var array=["尽子轨","渣渣将","swift"]

init(coder aDecoder:NSCoder!){
super.init(coder:aDecoder)
self.dataSource=self
}
init(frame: CGRect) {
super.init(frame: frame)
// Initialization code
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return 1
}

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell : AnyObject!=tableView.dequeueReusableCellWithIdentifier("cell")
var label=cell.viewWithTag(table_cell) as UILabel
label.text=array[indexPath.row]
return cell as UITableViewCell
}

func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return 3
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: