[英]How to show a new UIViewController without a NavigationController
[英]Show NavigationController in UIViewController
我有一个来自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)
}
当您使用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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.