How can I change the image displayed in a UIImageView programmatically?

后端 未结 15 727
孤街浪徒
孤街浪徒 2020-12-07 08:42

I have an IBOutlet to a UIImageView, but when I look at the UIImageView doc, I can\'t see any hints about programmatically changing it

15条回答
  •  情书的邮戳
    2020-12-07 09:28

    My problem was that I tried to change the image in an other thread. I did like this:

    - (void)changeImage {
        backgroundImage.image = [UIImage imageNamed:@"img.png"];
    }
    

    Call with:

    [self performSelectorOnMainThread : @selector(changeImage) withObject:nil waitUntilDone:NO];
    

提交回复
热议问题