Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cozzin/uihosting
🖼 Using SwiftUI in UITableViewCell
https://github.com/cozzin/uihosting
Last synced: 11 days ago
JSON representation
🖼 Using SwiftUI in UITableViewCell
- Host: GitHub
- URL: https://github.com/cozzin/uihosting
- Owner: cozzin
- Created: 2021-08-14T06:49:18.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-15T00:12:46.000Z (over 1 year ago)
- Last Synced: 2024-10-17T21:15:40.225Z (21 days ago)
- Language: Swift
- Homepage: https://medium.com/@hongseongho/uitableviewcell%EC%97%90%EC%84%9C-swiftui-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-43321a9e9e90
- Size: 34.2 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UIHosting
⚠️ Now, it's better to use [UIHostingConfiguration](https://developer.apple.com/documentation/SwiftUI/UIHostingConfiguration). Here is WWDC session that describe how to use it https://developer.apple.com/videos/play/wwdc2022/10072/
## 🚀 Motivation
- Using SwiftUI in UITableViewCell
- [UITableViewCell에서 SwiftUI 사용하기 - SwiftUI와 UIKit을 함께 사용하며 겪은 시행착오](https://medium.com/@hongseongho/uitableviewcell%EC%97%90%EC%84%9C-swiftui-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-43321a9e9e90)## 🧰 Setup
1. In your Xcode project, navigate to File > Swift Packages > Add Package Dependancy...
2. Paste the following into the URL field: https://github.com/cozzin/UIHosting## 🧑💻 Usage
```swift
import UIHostingprivate lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.register(UIHostingCell.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
cell.configure(ExampleSwiftUIRow(count: data[indexPath.row]))
return cell
}
```