Link to the subclass of UITableView如何使用CADisplayLink和UITableViewAutomaticDimension在不跳轉的情況下滾動時在UITableView上執行更新?
爲什麼UITableView在滾動時跳轉?你能幫我嗎?
爲一個誰幫助我,我開始和獎勵後ANOTHER賞金100 :-)
如何使用設置其contentOffset
一起執行上UITableView
一些變化?
這是我建立了我的scrollDisplayLink
:
scrollDisplayLink = CADisplayLink(target: self, selector: Selector("scrollTable"))
scrollDisplayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
cellForCurrentIndexPath?.hidden = true
,然後內scrollTable
我以下的事情:
func scrollTable() {
var newOffset = CGPointMake(currentContentOffset.x, currentContentOffset.y + scrollRate * 10)
if currentContentSize.height < frame.size.height {
newOffset = currentContentOffset
} else if newOffset.y > currentContentSize.height - frame.size.height {
newOffset.y = currentContentSize.height - frame.size.height
} else if newOffset.y < 0 {
newOffset = CGPointZero
}
contentOffset = newOffset
if coveredIndexPath != nil && coveredIndexPath! != currentIndexPath! {
let verticalPositionInCoveredCell = longPressGestureRecognizer.locationInView(cellForRowAtIndexPath(coveredIndexPath!)).y
if direction == .Down && heightForCoveredCell - verticalPositionInCoveredCell <= heightForCurrentCell/2 {
print("moved down")
beginUpdates() //1
moveRowAtIndexPath(currentIndexPath!, toIndexPath: coveredIndexPath!) //2
currentIndexPath = coveredIndexPath //3
endUpdates() //4
}
}
}
滾動是好的,除非線1-4
被註釋掉或停用UITableViewAutomaticDimension
。當它們未被評論時,當滾動時,currentContentOffset
不同,然後0
表跳躍。爲什麼會發生這種情況?線程還是其他問題?
注:
UITableView
工作原理與UITableViewAutomaticDimension
:
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}