滑动时快速获取黑屏

时间:2019-06-24 08:10:08

标签: swift

从主服务器加载所有设置后,在主vc中(在我的情节提要中有导航控制器和视图控制器),我显示新的vc

DispatchQueue.main.async {
  var stor: UIStoryboard!
  stor = UIStoryboard(name: "Profile", bundle: nil)
  let viewcontroller = stor.instantiateViewController(withIdentifier: "profileVC")
  let nav = UINavigationController(rootViewController: viewcontroller)
  self.present(nav, animated: true, completion: nil)   
}

profileVC

navigationController?.interactivePopGestureRecognizer!.delegate = self // enable swipe to back

// present new vc
var stor: UIStoryboard!
stor = UIStoryboard(name: "Settings", bundle: nil)
let viewcontroller = stor.instantiateViewController(withIdentifier: "settingsVC")
self.navigationController?.pushViewController(viewcontroller, animated: true)

但是有时我在刷屏时会出现黑屏image(在profileVC中)和image(在从profileVC推送的另一个vc中)

我该如何解决?

3 个答案:

答案 0 :(得分:0)

我认为您必须更改此语法

  • 来自
  mainView = UIStoryboard(name: "Profile", bundle: nil)
  mainView = UIStoryboard(name: "Main", bundle: nil)

答案 1 :(得分:0)

UINavigationController中删除profileVC,仅显示视图控制器。如果要显式添加导航控制器,请改用show(_ vc: UIViewController, sender: Any?)

编辑: 可能您正在寻找的流程如下:

UINavigationController-> MainViewController-> 显示 ProfileViewController

如何添加导航控制器:

  • 转到情节提要(假设您正在使用一个)
  • 选择视图控制器(主)
  • 编辑器->嵌入->导航控制器

PS:请勿强行打开您无法控制(最好是永远无法控制)的属性(navigationController?.interactivePopGestureRecognizer!.delegate = self

答案 2 :(得分:0)

我想您已经清除了视图的颜色,请仔细检查。清除视图的颜色时会发生这种情况。