gpt4 book ai didi

ios - 如何在 iOS 应用程序中使 ScrollView 高度动态化?

转载 作者:行者123 更新时间:2023-11-28 08:32:15 25 4
gpt4 key购买 nike

这是我的结构:

-View
-scrollview
-view
-stackview //main stackview
-stackview1
-label1
-label2
-stackview2
-label1
-label2
-stackview3
-label1
-label2
-stackview4
-label1
-label2
-stackview5 // this is the dynamic vertical stackview
-label1
-label2 //this is the dynamic label
-stackview6
-label1
-label2

我希望 ScrollView 基于 stackview5 是动态的。我将 stackview5 中的 label2 设置为 0 行。我还将分布设置为等间距。我还缺少什么?

最佳答案

我会使用 UITableView

你们六个堆栈 View 中的每一个都是他们自己的 tableViewCell

将此添加到已加载您的 TableViewController 的 View 中

self.tableView.estimatedRowHeight = 58.0 // whatever you want your default to be 
self.tableView.rowHeight = UITableViewAutomaticDimension

也将此方法添加到您的 TableViewController

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

关于ios - 如何在 iOS 应用程序中使 ScrollView 高度动态化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38645972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com