2017-10-19 56 views
0

我有一個UITable視圖,其頂部有一個視圖,然後是它下面的一些單元格。 這種層次的UITableView沒有正確地滾動到底部,直到點擊一個單元格

<tableview> 
<view></view> 
<cell></cell> 
<cell></cell> 
<cell></cell> 
</tableview> 

現在讓他們擴大根據標籤的高度,我有我的電池作爲動力高度,現在這個有一行標籤時工作正常,但是當我在標籤設置爲0 (多線)我的tableview反彈到頂部時,試圖滾動,但是當你這一點,春聯作爲它的意思後,點擊這些細胞之一,在底部細胞

enter image description here

進出口比較新爲了迅速,請記住這個答案

在此先感謝

這是代碼用於填充細胞

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
    { 

     myTableView.estimatedRowHeight = 50 
     myTableView.rowHeight = UITableViewAutomaticDimension 

     let cell = Bundle.main.loadNibNamed("ProfilerTableViewCell", owner: self, options: nil)?.first as! ProfilerTableViewCell 

     cell.cellDescription.text = RatingsDataSet[n].descriptions[indexPath.row] 
     if RatingsDataSet[n].valuesdata[indexPath.row][0] != "0" { 
      cell.valueLabel.setTitle(RatingsDataSet[n].valuesdata[indexPath.row][0], for: .normal) 
     }else{ 

      cell.valueLabel.setTitle("Not Set", for: .normal) 
      cell.valueLabel.backgroundColor = UIColor.lightGray 

     } 

     return(cell) 

    } 
+0

你的代碼在哪裏? –

+0

林不知道你需要什麼部分,因爲我不知道它出錯的地方,我已經添加了填充單元格的代碼 – Ray

回答

2

這兩條線:

myTableView.estimatedRowHeight = 50 
    myTableView.rowHeight = UITableViewAutomaticDimension 

屬於在viewDidLoad(),不是你擁有它們。移動這些可能是你需要做的所有事情來糾正問題。

+0

這就是那個謝謝你! – Ray

相關問題