IOS真机切换UI界面时,出现“Only run on the main thread” 的解决方法

[[[YXGSDK sharedInstance] GetViewController] presentViewController:ForgotPasswdV2 animated:NO completion:nil];


真机环境下,UI的处理必须是单线程的,所以当 在一个已存在的UI上切换新的UI时,会出现Only run on the main thread 错误。告诉你,只能在主线程上运行。

那么解决方法是:

                        dispatch_async(dispatch_get_main_queue(), ^{

                            [[[YXGSDK sharedInstance] GetViewController] presentViewController:ForgotPasswdV2 animated:NO completion:nil];

                        });


哈哈,在单线程里就可以啦~

你可能感兴趣的:(IOS)