Link to the subclass of UITableViewジャンプしないでCADisplayLinkとUITableViewAutomaticDimensionを使用してスクロールしながらUITableViewで更新を行う方法は?
スクロール中にUITableViewがジャンプするのはなぜですか?私を助けることができますか?私は開始私を助ける1と受賞のため
100の後にANOTHER恵み
:-)そのcontentOffset
を設定するとともにUITableView
にいくつかの変更を実行する方法は?
これは私が私のscrollDisplayLink
を設定する方法です:
scrollDisplayLink = CADisplayLink(target: self, selector: Selector("scrollTable"))
scrollDisplayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
cellForCurrentIndexPath?.hidden = true
、その後scrollTable
以内に私は物事を次のようにします。行が1-4
コメントしているか、私はUITableViewAutomaticDimension
を無効にしない限り
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
}
}
}
スクロールは結構です。それらがコメントされていないときには、currentContentOffset
が異なるときにテーブルがジャンプし、0
がスクロールします。なぜそんなことが起こるの?スレッドや他の何かに問題はありますか?
注:
UITableView
がUITableViewAutomaticDimension
で動作します:
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}