I'm trying to make an iOS app. As part of the app, I want a UIScrollView开发者_Go百科 to scroll every X seconds. I believe that I need to use NSTimer. Is this correct?
Yes. You can use NSTimer
for this:
float interval = 2.5f; //whatever interval you want
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:interval target:someTarget selector:@selector(someSelector:) userInfo:nil repeats:YES];
Yes. You can use NSTimer to perform either a delayed event or a periodic event. There is a good post on using NSTimer here.
Yes.
NSTimer* theTimer = [NSTimer scheduledTimerWithTimeInterval:X
target:someController
selector:@selector(scrollThatView)
userInfo:nil
repeats:YES];
You don’t need to use an NSTimer
—there are other ways to do it—but yes, an NSTimer
will allow you to do so.
精彩评论