2015-07-11 117 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