gpt4 book ai didi

ios - 在 iOS 中 x 秒后从 UIButton 更改 UIImage

转载 作者:行者123 更新时间:2023-11-28 19:05:40 25 4
gpt4 key购买 nike

我正在尝试在 1 秒后从 uibutton 更改 uiimage。我试着让线程休眠

[button1 setImage:[UIImage imageNamed:@"sameThing.png"] forState:UIControlStateNormal];

[NSThread sleepForTimeInterval:1];

[button1 setImage:[UIImage imageNamed:@"interrogation.png"] forState:UIControlStateNormal];

但是图像没有变化,Thread正常执行感谢您的建议

最佳答案

试试这个

[self performSelector:@selector(updateBtnImage:)
withObject: someObject
afterDelay:1];



-(void) updateBtnImage: (id) obj
{
//Set image here
//If still not updating image here dispatch block on main thread manually like this
dispatch_async(dispatch_get_main_queue(),
^{
//Set image in this block
});

}

关于ios - 在 iOS 中 x 秒后从 UIButton 更改 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20639347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com