How do I adjust my popover to the size of the content in my tableview in swift?

后端 未结 6 1102
情话喂你
情话喂你 2021-01-31 03:17

I\'m using popoverPresentationController to show my popover. The UITableViewController used to show as popover is created programmatically and will usu

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 03:33

    Checkout the preferredContentSize property of UIViewController:

    let height = yourDataArray.count * Int(popOverViewController.tableView.rowHeight)
    popOverViewController.preferredContentSize = CGSize(width: 300, height: height)
    

提交回复
热议问题