iphone - 用户交互后刷新屏幕

标签 iphone objective-c ios xcode sleep

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

相关文章:

iphone - 如何在 Objective-C 中将 int 转换为 NSTimeInteravl?

iphone - 如何在iphone项目中添加C++文件

iphone - objective-c 中UINavigationBar右侧的UISearchBar

ios - 检测蓝牙信号的准确频率

ios - Swift 中的模块化文本占位符 block

ios - 带有数组值的 Swift 字典

当我使用 subview 调用父 View 时,iOS UIPageControl 不显示正确的页码

Objective-C - 使用 OCMock 模拟分段控件?

objective-c - 在 Objective C 中将 float 舍入为 1/4

html - IOS8 : whole page scrolls down when input in fixed footer gets focus