Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何设置自定义UITableView的高度?_Ios_Swift_Uitableview_Height - Fatal编程技术网

Ios 如何设置自定义UITableView的高度?

Ios 如何设置自定义UITableView的高度?,ios,swift,uitableview,height,Ios,Swift,Uitableview,Height,我将使用动态数量的单元格,并在此基础上调整表的高度。我可以自己解决这个问题,因为我似乎无法调整桌子的大小。无论我使用100个单元格还是10个单元格,视图都设置在相同的高度 class generalTableViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { tableView.rowHeight = UITableViewAutomaticD

我将使用动态数量的单元格,并在此基础上调整表的高度。我可以自己解决这个问题,因为我似乎无法调整桌子的大小。无论我使用100个单元格还是10个单元格,视图都设置在相同的高度

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
    }
}

UITableViewController通常接管整个视图。要使用UITableView仅占用视图的一部分,请使用UIViewController

如果要管理的视图由多个子视图组成(其中只有一个子视图是表视图),则应使用UIViewController子类而不是UITableViewController子类来管理表视图。UITableViewController类的默认行为是使表格视图填充导航栏和选项卡栏之间的屏幕(如果有)


有关Apple指南,请参阅。基本上,您只需要处理控制器通常会为您处理的一些事情。

使用-:heightforrow tableview的dexpath方法是否尝试设置
UITableViewCell
高度?或者
UITableView
高度?我可以调整UITableViewCell,这是我遇到问题的UITableView。我尝试使用UIViewController,但仍然无法绕过高度限制。我可能使用了错误的术语。当我滚动时,如果我有1000行,它只允许我滚动一个固定的距离,所以如果我有更多的行,我永远不能超过这个距离。