PerformSelectorOnMainThread 的奇怪之处
只是被奇怪的事情困住了。我有以下代码:
-(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:UIControlEventTouchUpInside];
[img release];
}
它因无法识别的选择器发送到实例错误而崩溃。上面的代码有什么问题吗?
提前致谢
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:UIControlEventTouchUpInside];
[img release];
}
and it crashes with Unrecognized selector sent to instance error. what's wrong with the code above?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您的方法被声明为
相应的选择器是
@selector(updateImageButton)
没有尾随冒号。更改:到
并且它应该可以工作。
Since your method was declared as
the corresponding selector is
@selector(updateImageButton)
without a trailing colon. Change:to
and it should work.