ios - Presenting ViewController会被加载但不会出现

标签 ios swift

呈现的 ViewController 似乎已加载,但屏幕实际上并未重新加载。触摸屏幕后,ViewController 可见。 这是我的 instantiateViewController 代码:

let v = self.storyboard?.instantiateViewController(withIdentifier: "BrowsingDaragaViewController") as! BrowsingDaragaViewController
self.present(v, animated: true, completion: nil)

BrowsingDaragaViewController 中没有额外的代码。在我触摸屏幕之前,viewDidAppear() 函数不会被调用。 我将 Xcode 9 与 Swift4 结合使用。

编辑:

演示代码在 tableview(didSelectedRow at indexPath) 但是当我在按钮操作中它工作正常

最佳答案

如果您使用过任何手势识别器,请将其移除并检查它是否会导致问题?

如果您不使用手势识别器,请在 didSelectRowAtIndexPath 中使用以下代码

// Your stuff
DispatchQueue.main.async(execute: {
   self.present(yourViewControllerHere, animated: true, completion: nil)
})
// Your stuff

仍然面临问题,然后确保您的 tableView 在 XIB 或 StoryBoard 中设置了单一选择。

关于ios - Presenting ViewController会被加载但不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46661774/

相关文章:

ios - 在 iOS Swift 中设置按钮事件颜色的简单方法

ios - XCode: ScrollView 不滚动

ios - UITextView 中的视频

ios - 清除 iOS 中的应用程序缓存适用于 Google+ 登录,但不适用于 Facebook

ios - 从 Swift 2.2 升级到 Swift 3.0 后, `continue` 的使用不明确

ios - 如何在另一个 ViewController 中加载 UIViewController XIB?

swift - 在 swift 中实现手势识别器后,如何找到按钮标签?

ios - 如何快速过滤 UICollectionView 中的单个类别?

ios - 如何将 CollectionView 添加到 TableViewCell 并检测 CollectionView 何时完成加载单元格以请求 TableViewCell 高度更新

ios - Xcode 11.2.1 错误 : Storyboard not editable