[英]How to show a pop up UIViewController with a UICollectionView in it in Swift?
The UIViewController with UICollectionView works fine if I launch it from storyboard. 如果我从情节提要中启动,带有UICollectionView的UIViewController可以正常工作。 However, when I try to launch it like this:
但是,当我尝试像这样启动它时:
let imagePicker = imagePickerControllerViewController()
imagePicker.modalPresentationStyle = .OverCurrentContext
presentViewController(imagePicker, animated: true, completion: nil)
It crashes on line: 它崩溃在线:
collectionView.dataSource = self
The question is, how to show a UIViewController (that has a UICollectionView) modally properly? 问题是,如何正确显示模态显示的UIViewController(具有UICollectionView)?
Replaced : 替换为:
let imagePicker = imagePickerControllerViewController()
With: 附:
let imagePicker = storyboard.instantiateViewControllerWithIdentifier("imagePicker") as! imagePickerControllerViewController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.