Avatar
UITableViewDataSourceのcellForRowAt内でUIHostingControllerを使ってSwiftUIで作ったViewをCellに表示した場合、iOS16未満だとスクロール時にレイアウトが崩れるのですがワークアラウンドご存知の方いましたらご教示お願いいたします。 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = UITableViewCell(style: .default, reuseIdentifier: "Cell") let hostingController = UIHostingController(rootView: SwiftUICellView()) cell.contentView.addSubview(hostingController.view) hostingController.view.translatesAutoresizingMaskIntoConstraints = false [ hostingController.view.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor), hostingController.view.topAnchor.constraint(equalTo: cell.contentView.topAnchor), hostingController.view.leftAnchor.constraint(equalTo: cell.contentView.leftAnchor), hostingController.view.rightAnchor.constraint(equalTo: cell.contentView.rightAnchor) ].forEach { $0.isActive = true } return cell } (edited)