Swift - 如何在从外部服务器验证后以编程方式更改视图
Swift - How to change view programmatically after validating from outside server
我有一个登录视图页面,一旦登录被验证,该页面应该转换为选项卡视图控制器。但是,在 session.dataTask
中实例化视图时出现错误
[24249:381955] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.
结果是
terminating with uncaught exception of type NSException
如何验证用户并在从服务器验证后将他带到主页?
这是因为您不应该在后台线程上执行该操作。
将您的实例化代码移至主线程
DispatchQueue.main.async {
// view instantition here.
}
我有一个登录视图页面,一旦登录被验证,该页面应该转换为选项卡视图控制器。但是,在 session.dataTask
中实例化视图时出现错误[24249:381955] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.
结果是
terminating with uncaught exception of type NSException
如何验证用户并在从服务器验证后将他带到主页?
这是因为您不应该在后台线程上执行该操作。
将您的实例化代码移至主线程
DispatchQueue.main.async {
// view instantition here.
}