我無法理解如何將視圖嵌入到具有動態高度的滾動視圖中。我已經成功創建了滾動視圖,但只有靜態高度。例如,Facebook應用程序(例如Facebook或Instagram)將如何管理爲動態高度數據的整個提要創建滾動視圖。到目前爲止,我已經使用storyboard來創建滾動視圖,但我認爲這在代碼中完成會好得多。在Swift中使用動態高度滾動視圖
class connectDetailsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//set up variables with data
fillData()
}
override func viewWillAppear(animated: Bool) {
let nameTitleString = String(businesses[businessNum]["name"]!)
nameTitle.text = nameTitleString
processTimes() // Adds information for the hours of operation, if applicable
processDetails() //Adds information for the details if possible (a few sentences to a few paragraphs)
}
}
processDetails()和ProcessTimes()將編輯堆棧內容看,我怎麼可以創建一個滾動視圖在正確的高度涵蓋這兩種堆看法?
我同意@Scriptable。強烈建議使用'UITableView'作爲這樣的事情,但是如果你計劃顯示除單元格以外的項目,那麼你需要一個動態改變高度的滾動視圖。 我回答了一個非常類似的問題,在這裏介紹了一個特定的流程:http://stackoverflow.com/a/37367119/6361557 –