iphone - 从主线程或网页线程以外的线程获取网页锁。不应从辅助线程调用 UIKit

标签 iphone ios ipad

我遇到了一个错误

Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread

代码 NSString *tokenString=[NSString stringWithFormat:@"username=%@&password=%@",[[userName.text lowercaseString] MD5],[password.text MD5]];

我正在为 MD5 使用类文件。我从MD5得到的

这个 md5 导致线程锁定我如何删除这个警告

最佳答案

当您从辅助线程调用 UIKit 时会发生这种情况...

要解决此问题,请尝试以下操作

dispatch_sync(dispatch_get_main_queue(), ^{

//Call the function from here

});

[self performSelectorOnMainThread:@selector(yourmethod:)withObject:obj waitUntilDone:YES]

关于iphone - 从主线程或网页线程以外的线程获取网页锁。不应从辅助线程调用 UIKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16330773/

相关文章:

ios - 我想在我的 ios 项目中识别 iphone 版本

ios - 在iOS中安装Jmeter证书

android - Phonegap构建在phonegap应用程序开发中的作用是什么

iphone - 作为掩码的 CGImageRef 和不是掩码的 CGImageRef 有什么区别?

iOS iPhone 应用程序无法在 iPad 上填满屏幕

ios - 我可以选择我的应用程序最高支持 iOS 8.4 吗?

iphone - 将 facebook-json 与项目中现有的 JSON 库发生冲突

iphone - 未知类型名称 'TransportViewController'

ios - 如何避免#ifdef __x86_64__

ios - 在 Xcode 上找不到带有 iOS 8.1.2 模拟器的 iPad Air 2