UITableView从storyboard中加入cell

来源:互联网 发布:激战2捏脸数据 编辑:程序博客网 时间:2024/04/24 11:17

UITableView这个控件在ios中应用非常广泛。所以说说tableview在使用中的方法

用storyboard来做, 直接拖一个cell作为tableview的子控件,设置cell的class为自己的cell类

这样就可以在这个类里面定制cell

还有一个地方那就是identifier

 这个要在

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {        let cell = tableView.dequeueReusableCell(withIdentifier: "tablecell")        return cell!    }
中用到。


还有就是xib中也可以做,但是用xib来做的话会有个问题,cell中添加手势会崩溃,会报有多个Object。

1 0