我的初始视图控制器是从Storyboard创建的。它有一个添加UINavigation的按钮:
let navigationController = UINavigationController(rootViewController: ListViewController)
self.presentViewController(navigationController, animated: true, completion:nil)
appDelegate.window?.rootViewController = navigationController
ListViewController有一个UICollectionView。点击单元格(我将其子类化)调用委托方法返回ListViewController并使用UICollectionView呈现另一个View:
let detailedListViewController = DetailedCollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())
self.navigationController?.pushViewController(detailedListViewController, animated: true)
在这个DetailedCollectionView中,每个单元格都有一个按钮来显示全屏SFSafariViewController。和以前一样,使用委托我试图像这样展示:
SFSafariVC = SFSafariViewController(URL: urlToLoad)
SFSafariVC.view.frame = self.view.frame
self.presentViewController(SFSafariVC, animated: true, completion: nil)
通过这样做,我可以看到SFSafariView正常工作,但我收到消息:
警告:尝试出示< UIAlertController:0x7fcd96353e20>上 < UINavigationController:0x7fcd948a0600>谁的观点不在 窗口层次结构!
我尝试将self.presentViewController
更改为self.navigationController?.presentViewController
,但仍然存在相同的错误。