美文网首页
iOS在闭包中跳转页面,出现部分元素不显示的状况

iOS在闭包中跳转页面,出现部分元素不显示的状况

作者: 咸鱼有只喵 | 来源:发表于2018-08-21 11:37 被阅读11次

代码如下:

 saveManager?.store(com, storeUrl: newUrl, success: {    
                let vc =  CheckViewController()
                self.present(vc, animated: true, completion: nil)
                print("combine success")
        }

解析:
因为在闭包中使用了异步函数,导致UI未在主线程刷新,这时候需要将vc的定义和跳转方法写在主线程中:

                DispatchQueue.main.async {
                 let vc =  CheckViewController()
                 self.present(vc, animated: true, completion: nil)
                 print("combine success")
                }

相关文章

网友评论

      本文标题:iOS在闭包中跳转页面,出现部分元素不显示的状况

      本文链接:https://www.haomeiwen.com/subject/ulvdiftx.html