加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift_ uitableview使用自定义(xib)cell

发布时间:2020-12-14 06:57:53 所属栏目:百科 来源:网络整理
导读:新建cell: 使用: 向 tableview 注册 nib 全局变量 let cellIdentifier = " myCell " myTableView !. registerNib ( UINib (nibName: " MyCell " ,bundle: nil ),forCellReuseIdentifier: cellIdentifier ) 然后在 cellForRowAtIndexPath 方法中使用: func

新建cell:


使用:

向 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 = tableView!.dequeueReusableCellWithIdentifier(cellIdentifier,forIndexPath: indexPath)

returnmycell

}

至此,一个简单地自定义cell已经实现!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读