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