我有一个来自Cell的UICollectionView它来到另一个带有Zoom Animation的UIViewController。我必须使用UINavigationController嵌入它,但是当它在模拟器中启动时它不会显示UINavigationController。问题是什么 ? 感谢帮助。
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
collectionView.deselectItemAtIndexPath(indexPath, animated: true)
let cell: PhotoCell = collectionView.cellForItemAtIndexPath(indexPath)as! PhotoCell
let detailViewController = storyboard?.instantiateViewControllerWithIdentifier("FullPhotoController") as! FullPhotoController
let attributes = collectionView.layoutAttributesForItemAtIndexPath(indexPath)
let attributesFrame = attributes?.frame
let frameToOpenFrom = collectionView.convertRect(attributesFrame!, toView: collectionView.superview)
transitionDelegate.openingFrame = frameToOpenFrom
let picture = everypicture[indexPath.row]
detailViewController.currentpicture = picture
detailViewController.transitioningDelegate = transitionDelegate
detailViewController.modalPresentationStyle = .Custom
presentViewController(detailViewController, animated: true, completion: nil)
}
答案 0 :(得分:0)
使用StoryboardId从Storyboard引用ViewController时,它会忽略它可能嵌入的任何导航视图。因此,您必须执行以下操作。为简洁起见,我省略了一些设置代码。
let detailViewController: UIViewController = self.storyboard!.instantiateViewControllerWithIdentifier("FullPhotoController") as! FullPhotoController
let navigationController: UINavigationController = UINavigationController(rootViewController: detailViewController)
navigationController.modalPresentationStyle = .Custom
navigationController.transitioningDelegate = transitionDelegate
self.presentViewController(navigationController, animated: true, completion: nil)