我想在回调事件中创建一个NSTimer对象(滚动视图我想开发一个像刷新一样的facebook或reeder,如果他们在最后持有一些时间滚动视图)
我已经意识到如果我正在创造一个时间,如果计时器正在获得nill imideaty:
backTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(backButton) userInfo:nil repeats:NO];
NSLog(@"backtimer : %@ ", backTimer.timeInterval);
2011-12-12 14:42:57.733 BabyTapBook[16825:13103] backtimer : (null)
所以我正在寻找正确的方法来实现这项功能
答案 0 :(得分:0)
const int kYourTimeInterval = 1; // the time in seconds - the interval at which your method is called
aTimer = [NSTimer scheduledTimerWithTimeInterval:kYourTimeInterval target:self selector:@selector(youMethodHere) userInfo:nil repeats:YES];
要终止它,请使用[aTimer invalidate];
答案 1 :(得分:0)
我在这里找到了答案: UIScrollView pauses NSTimer until scrolling finishes
[[NSRunLoop mainRunLoop] addTimer:backTimer forMode:NSRunLoopCommonModes];