Add UITableView with dynamic prototype cells in XIB

I am trying to add a UITableView element to a XIB which I want to present as a sheet from the bottom but I only get the option of static cells. Isn't it possible to have dynamic tables within a XIB or am I missing something?

Accepted Reply

I have managed to achieve my goal by creating a Storyboard and assign it to my custom UIViewController class.

Make sure to set the Class and Storyboard ID:

The code to present and use the Storyboard from the the presenting ViewController:

let popup = UIStoryboard(name: "MyPopupVC", bundle: nil).instantiateViewController(withIdentifier: "myPopupUniqueID") as! MyPopupVC

if let sheet = popup.sheetPresentationController {
sheet.detents = [.large()]
sheet.prefersGrabberVisible = true
}
popup.set(account: account) //Transfer account object to popup VC
present(popup, animated: true)

Replies

I have managed to achieve my goal by creating a Storyboard and assign it to my custom UIViewController class.

Make sure to set the Class and Storyboard ID:

The code to present and use the Storyboard from the the presenting ViewController:

let popup = UIStoryboard(name: "MyPopupVC", bundle: nil).instantiateViewController(withIdentifier: "myPopupUniqueID") as! MyPopupVC

if let sheet = popup.sheetPresentationController {
sheet.detents = [.large()]
sheet.prefersGrabberVisible = true
}
popup.set(account: account) //Transfer account object to popup VC
present(popup, animated: true)