Swift UITableView使用自定义cell
uitableview 使用 xib 的自定义cell 新建cell:(假如命名 MyCell)
使用: 向 tableview 注册 nib 全局变量 letcellIdentifier ="myCell" myTableView!.registerNib(UINib(nibName:"MyCell",bundle:nil),forCellReuseIdentifier:cellIdentifier) 然后在cellForRowAtIndexPath 方法中使用: functableView(tableView:UITableView!,cellForRowAtIndexPath indexPath:NSIndexPath!) ->UITableViewCell!{ //系统cell的简单用法 //let cell = UITableViewCell(style:.Default,reuseIdentifier:"myCell") //cell.textLabel.text = "swift cell (indexPath.row)"
varmycell :MyCell= tableView!.dequeueReusableCellWithIdentifier(cellIdentifier,forIndexPath: indexPath)asMyCell returnmycell } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |