我有一個UITableView
自定義單元格。它有一個UIView
和一個UIButton
我想改變這個視圖高度約束和按鈕的頂部約束在我的`cellForRowAtIndex編程。所以在這裏,我這樣做。CellForRowAtIndex中以編程方式更改單元格子視圖約束
if(myintime2 == "00:00" && myoutTime2 == "00:00" )
{
cell.btnIntime2.setTitle(myintime2, for: .normal)
cell.btnOutTime2.setTitle(myoutTime2, for: .normal)
cell.btnOutTime2.isHidden=true
cell.btnIntime2.isHidden=true
cell.customViewHeightConstraint.constant = 111
cell.customBtnIn1Top.constant = 111/2
}
else if (myintime2 == "N/A" && myoutTime2 == "N/A")
{
cell.btnIntime2.setTitle(myintime2, for: .normal)
cell.btnOutTime2.setTitle(myoutTime2, for: .normal)
cell.btnOutTime2.isHidden=true
cell.btnIntime2.isHidden=true
cell.customViewHeightConstraint.constant = 111
cell.customBtnIn1Top.constant = 111/2
}
else
{
cell.btnIntime2.setTitle(myintime2, for: .normal)
cell.btnOutTime2.setTitle(myoutTime2, for: .normal)
cell.customViewHeightConstraint.constant = 222
cell.customBtnIn1Top.constant = 10
cell.btnOutTime2.isHidden=false
cell.btnIntime2.isHidden=false
}
但有些細胞的高度是錯誤的,請幫我
你是什麼意思,「有些細胞的高度是錯誤的」?預期的結果是什麼,取而代之的是什麼? –
@mag_zbc我必須檢查2個條件..如果我的time2可用,我想增加單元格的高度並增加按鈕的最高限制值。但是當我的條件不滿足時,細胞正在增加,最高也在增加。 – user1960169
@mag_zbc但不適用於所有單元格,這種情況僅適用於少數單元格。隨機 – user1960169