开发者

How to auto-scroll UITableView?

I am trying to do something interesting.

I am pulling some JSON data and populating cells in a UITableView. How can I make the UITableView scroll ever second or so? I want to g开发者_如何学运维ive the effect that as new data is coming in, the table is scrolling, so it is streaming.

Any ideas?


Yes, use scrollToRowAtIndexPath:atScrollPosition:animated:.

You could also use UIScrollView's scrollRectToVisible:animated: if you want to have more finegrained control and can calculate exactly what your scroll position should be in pixels. (UITableView is subclass of UIScrollView.)

But if you are just adding cells, sounds like you could also just use insertRowsAtIndexPaths:withRowAnimation:, this is also "interesting."


Just do this

[table reloadData];



NSIndexPath *myIP = [NSIndexPath indexPathForRow:[arrayIn count]-1 inSection:0] ;


  [table scrollToRowAtIndexPath:myIP atScrollPosition:NULL animated:YES];

in anywhere where arrayIn is your array by which your table populate.


you can use uitableviews scrollToRowAtIndexPath to do this....heres a link reference

You can call this method whenever as youd like to scroll your tableview


And you can call performSelector:withObject:afterDelay: for the timer effect - although if you are really pulling in data every second, it's best to just reloadData as you go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜