我正在尝试在 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/