cuốn sách gpt4 ai đã làm

performanceSelectorOnMainThread lạ

In lại Tác giả: Walker 123 更新时间:2023-11-28 18:08:02 26 4
mua khóa gpt4 Nike

只是遇到了奇怪的事情。我有以下代码:

-(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];
}

它崩溃并显示无法识别的选择器发送到实例错误。上面的代码有什么问题?

Cảm ơn trước

câu trả lời hay nhất

因为你的方法被声明为

-(void)updateImageButton

相应的选择器是 @selector(updateImageButton) 没有尾随冒号。 更改:

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

đến

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

它应该可以工作。

关于objective-c - performSelectorOnMainThread 奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6056420/

26 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress