iphone - 设置隐藏 : has unwanted delay

标签 iphone ios objective-c uikit grand-central-dispatch

我目前有一个非常奇怪的错误。

一个方法被调用,它应该通过停止它来隐藏一个 UIActivityIndi​​catorView(启用停止时自动隐藏)和一个名为 badIndicatorUIImageView.

作为替代,它应该显示另一个名为 goodIndicatorUIImageView

[goodIndicator setHidden:NO];
[badIndicator setHidden:YES];
[refreshIndicator stopAnimating];
NSLog(@"statussetting good should be completed");

控制台会立即打印以下内容,但大约需要三秒钟才能在屏幕上显示更改。

2013-05-31 20:24:57.835 app name[5948:1603] statussetting good should be completed

我已尝试在对象和父 View 上调用 setNeedsDisplay 方法,并将 hidden 替换为 alpha。 仍然遇到同样的问题。

最佳答案

听起来您是从后台线程调用它。所有与 UIKit 的交互都需要在主线程中发生。尝试使用:

dispatch_async(dispatch_get_main_queue(), ^{
    [goodIndicator setHidden:NO];
    [badIndicator setHidden:YES];
    [refreshIndicator stopAnimating];
    NSLog(@"statussetting good should be completed");
});

关于iphone - 设置隐藏 : has unwanted delay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16863825/

相关文章:

ios - 当单元格出现时使用 AutoLayout 为 UITableViewCell 内容设置动画

ios - iOS Message App Extension插入标签错误代码6

ios - AVPlayer 不播放来自服务器的视频?

iphone - UITextView 不响应另一个 UITextView 附件 View iPhone?

ios - Eroor 将 NSPredicate 与 Swift "Could not find an overload for ' init 中的 block 一起使用,它接受提供的参数”

iOS - 后台 AVAudioSession 路由更改通知

ios:webview 滚动不起作用

objective-c - UIImage - 根据温度调整图像

iphone - 由于 _NSURLIsExcludedFromBackupKey 错误导致 Phonegap 1.9.0 应用程序崩溃

iphone - 实时 GKMatch 断开连接问题