我有這樣的TableView異常行爲添加多個小區的TableView中
當視圖顯示它工作正常,當我添加一行它工作正常過,當我添加第二個,第三,ECC ...排它開始有這個問題:
(而不是隻具有段下去的時候,它會顯示兩者)Segmet是建立與固定點圖像和中間兩個部分:一個up和一個d自己的,並從該行根據,我展示一個頂段,或者只有底部或兩個:
cell.centralDotIV.image = UIImage(named: "Dot")
if array.count > 1 {
if indexPath.row == 0 {
cell.lowerLineIV.image = UIImage(named: "Line")
} else if indexPath.row == array.count - 1 {
cell.upperLineIV.image = UIImage(named: "Line")
} else {
cell.upperLineIV.image = UIImage(named: "Line")
cell.lowerLineIV.image = UIImage(named: "Line")
}
}
這裏的那裏每一次按鍵增加該小區獲得拍了拍代碼:
@IBAction func addDateTapped(sender: UIBarButtonItem) {
array.append(NSDate())
var i = 0
var indexArray = [NSIndexPath]()
for _ in array {
let index = NSIndexPath(forRow: i, inSection: 0)
indexArray.append(index)
i++
}
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: .Fade)
if array.count != 1 { tableView.reloadRowsAtIndexPaths(indexArray, withRowAnimation: .Fade) }
}
我試過甚至每次點擊按鈕時重新加載表格都是一樣的。怎麼了?
你說得對,謝謝! –
隨着你的「因素分析」你贏得了一切! –