0
我想获得一个按钮来创建一个NSTimer,它反过来会调用一个函数(refreshView)刷新UI元素,但我有问题,我不知道问题出在哪里。方法签名是否错误?或者我得到的NSRunLoop部分错了?或者它只是可怕的基地?任何帮助表示赞赏。NSInvocation问题NSTimer和NSMethodSignature
-(IBAction)reload:(id)sender{
NSInvocation *displayInvocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(refreshView)]];
[displayInvocation setTarget:self];
NSTimer *slideShowTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
invocation:displayInvocation
repeats:YES];
[slideShowTimer fire];
NSRunLoop * a = [NSRunLoop currentRunLoop];
[a addTimer:slideShowTimer forMode:NSRunLoopCommonModes];}
-(void)refreshView{
[slideshow1 displayWithView:MajorImageView topicLabel:TopicLabel];
}
为了清楚起见,应该提到用'scheduledTimer ...'创建的定时器已被_already_添加到运行循环中。定时器也不需要发送'fire'。 – 2012-02-11 19:03:09
谢谢,它现在工作完美! – 2012-02-12 18:56:59