- Using SwiftUI in UITableViewCell
- UITableViewCell에서 SwiftUI 사용하기 - SwiftUI와 UIKit을 함께 사용하며 겪은 시행착오
- In your Xcode project, navigate to File > Swift Packages > Add Package Dependancy...
- Paste the following into the URL field: https://github.com/cozzin/UIHosting
import UIHosting
private lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.register(UIHostingCell<ExampleSwiftUIRow>.self, forCellReuseIdentifier: "UIHostingCell")
tableView.delegate = self
tableView.dataSource = self
return tableView
}()
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "UIHostingCell", for: indexPath) as! UIHostingCell<ExampleSwiftUIRow>
cell.configure(ExampleSwiftUIRow(count: data[indexPath.row]))
return cell
}