How can i create a `UITableViewCell` in Compose Mu...
# compose-ios
v
How can i create a
UITableViewCell
in Compose Multiplatform?
v
Thanks, but I have a function which needs to return an instance of
UITableViewCell
Copy code
override fun cellForMentionsEntity(
        entity: HKWMentionsEntityProtocolProtocol?,
        withMatchString: String?,
        tableView: UITableView?,
        atIndexPath: NSIndexPath?
    ): UITableViewCell?
How can i use UiKitView here?
a
I think the most likely way for you is to subclass from
UITableViewCell
and override
reuseIdentifier
.
However, if you're no familiar with
UITalbeView
api, I would recommend check it first - because in most cases you don't need to create cell by youtselve.
v
I found this piece of code
Copy code
tableView?.registerNib(
    nib = UINib.nibWithNibName("UserTableViewCell", null),
    forCellReuseIdentifier = "userCell"
)
return tableView?.dequeueReusableCellWithIdentifier("userCell")?.apply {
    this.contentView = 
}
But i cannot set
contentView
to a
ComposeUiViewController().view
as its a
val
a
Not sure it's a good approach. First of all, compose content is not self-sizing. Second, if you're suppose to use compose inside every cell, you most likely get memory consumption and performance issues. So, I would recommend to create entire table in Compose and consider your code only if it's not possible. About your code - sample is very wrong. Please check
UITableView
api and how to create cells without interface file. For example, here: https://medium.com/thecodr/uitableview-uitableviewcell-without-storyboard-swift-5-2cc1d608be6c
v
Thanks, i'll check this The problem is that, I am using a library Hakawai which does not let me create a dropdown menu of my own and I have to implement the UiTableViewCell So, what you mean is having composable content inside a UITableViewCell will have very bad performance?
a
In case your table has lots of cells - that might me a problem because every compose controller is quite a heavy object. You will probably need to implement cell reusing properly. Also, don't forget to manage child-parent connection between your view controller and ComposeUIViewContoller - that's a framework requirement.