开发者

performSelectorOnMainThread strangeness

just stuck with strange thing. I have the following code:

-(void)ImageDownloadCompleat
{
    [self performSelectorOnMainThread:@selector(updateImageButton:) 
                           withObject:nil 
                        waitUntilDone:YES];
}

-(void)updateImageButton {
    NSLog(@"image OKEY");
    UIImage *img = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:
                                                     @"%@/%@.jpg",pathPreview,self.idProducts]];
    //images.image = img;

    [images setBackgroundImage:img forState:UIControl开发者_JAVA技巧EventTouchUpInside];
    [img release];
}

and it crashes with Unrecognized selector sent to instance error. what's wrong with the code above?

Thanks in advance


Since your method was declared as

-(void)updateImageButton

the corresponding selector is @selector(updateImageButton) without a trailing colon. Change:

[self performSelectorOnMainThread:@selector(updateImageButton:) 
                       withObject:nil 
                    waitUntilDone:YES];

to

[self performSelectorOnMainThread:@selector(updateImageButton) 
                       withObject:nil 
                    waitUntilDone:YES];

and it should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜