我正在用 xcode 为 iO 编写一个应用程序。我有这样的代码:
- (void)buttonAction:(UIButton*)sender{
UIView *figure = (UIView *) [figures objectAtIndex:sender.tag];
[figure.layer setBorderWidth:2.0f];
[figure.layer setBorderColor: [UIColor greenColor].CGColor];
sleep(1);
[self cleanScreen];
}
- (void) cleanScreen {
//Some code to hide all view objects
}
我希望在 cleanScreen 函数删除项目之前,边框颜色和宽度的更改会在屏幕上反射(reflect) 1 秒钟。但是碰巧这些更改没有反射(reflect)出来,花费了一秒钟的元素被删除了。
我想在调用 cleanScreen 之前刷新屏幕。
如何得到我想要的效果?
提前致谢!
最佳答案
代替:
sleep(1);
使用:
[self performSelector:@selector(cleanScreen) withObject:nil afterDelay:1];
使用 sleep()
可以卡住整个应用程序
关于iphone - 用户交互后刷新屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13827500/