2015-07-11 42 views
0

我有一個tableView在swift中~500個單元格。我希望它在沒有任何用戶輸入的情況下自行滾動。有點像股票報價器顯示信息。我該怎麼做呢?另外,當它觸及底部時,我希望它再次從頂部開始。有沒有任何方法或工具可以做到這一點?Swift:Xcode tableView無限期滾動

+0

這聽起來並不像表視圖確實是一個合適的視圖。如果它只是一個自動收報機。應該相當容易地推出自己的自動收報機,以便在所需方向重複使用和生成動畫。 SpriteKit會讓這個非常簡單。 – uchuugaka

回答

2

您可以使用scrollToRowAtIndexPath並與UIView

animateWithDuration方法結合起來
var indexPath = NSIndexPath(forRow: rowNumberHere, inSection: 0) 
self.tableview.scrollToRowAtIndexPath(indexPath, 
       atScrollPosition: UITableViewScrollPosition.Bottom, animated: true) 

你也可以使用定時器滾動每次到下一個單元格,當你到達最後一個單元格喲你再一次滾動到頂部逐個細胞。

var timer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: Selector("roll"), userInfo: nil, repeats: true) 


func roll() { 
    // scroll to next row until we reach the last cell, in that case scroll back until reach the first cell 
} 

This SO question可以幫助,但它是在Objective-C