使用 UIView xib 作为表格视图单元格 [英] Using a UIView xib as a Table View Cell

查看:34
本文介绍了使用 UIView xib 作为表格视图单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIView 的 xib,类为 MyUIView.我想将此视图重新用作表格视图单元格,但我不知道该怎么做.

I have a xib that is a UIView, with class MyUIView. I'd like to re-use this view as a Table View Cell, but I'm not sure how I would do that.

我知道我必须为我的表格视图注册 xib,例如:

I know I have to register the xib for my table view, like:

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.register(UINib(nibName: "MyUIView", bundle: nil), forCellReuseIdentifier: "MyUIView")
}

但除此之外,我不知道如何将其向上转换为表视图单元格.我需要对常规的表视图/表视图单元格进程进行哪些修改才能使用我的 UIView xib 作为单元格?

But other than that, I'm not not sure how to upcast it to a Table View Cell. What modifications do I need to make to the regular Table View/Table View Cell process to use my UIView xib as the cell?

推荐答案

UIView 控件 添加到您的表格视图单元格.然后将其类设置为 MyUIView.

Add a UIView control to your table view cell. Then set its class to MyUIView.

这篇关于使用 UIView xib 作为表格视图单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆