私は、動的な数のセルを使用し、その基準でテーブルの高さのサイズを変更します。私はテーブルのサイズを変更するように見えないので、これを自分で行う方法を考え出すことができます。私が100のセルを使うか10を使うかは、同じ高さに設定されます。カスタムUITableViewの高さを設定するにはどうすればよいですか?
class generalTableViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) {
tableView.rowHeight = UITableViewAutomaticDimension
// self.tableView.contentSize.height = 2000
// self.tableView.frame.size.height = 2000
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1000
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
return cell
}
}
使用: - tableViewのheightForRowAtIndexPathメソッド –
'UITableViewCell'の高さを設定しようとしていますか?または 'UITableView'の高さですか? –
私はUITableViewCellを調整することができます、それは私が問題を抱えているUITableViewです。 – user6688986