views:

185

answers:

3

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 give the effect that as new data is coming in, the table is scrolling, so it is streaming.

Any ideas?

A: 

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

Daniel
A: 

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.

Paul Lynch
Where in my code would I invoke this?
Sheehan Alam
Anywhere you like. But at the point where you load the data would be logical, and create a method to perform that calls the perform method again. Or just use an NSTimer.
Paul Lynch
+2  A: 

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."

Jaanus