我在 viewWillAppear()
中注册了 registerNib
方法,当我使用 presentViewController(viewController, animated: true, completion: nil)
时,它工作正常。
但是当我使用 presentViewController(viewController, animated: false, completion: nil)
时,它不起作用。
错误 消息如下。我必须在 Storyboard上注册吗?无法通过程序注册?
'NSInternalInconsistencyException',
reason: 'could not dequeue a view of
kind: UICollectionElementKindCell with identifier NoContentsCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
最佳答案
在您的 Storyboard中设置可重复使用的标识符。
并使用collectionView.dequeueReusableCellWithReuseIdentifier
对于注册类
self.collectionView.registerClass(MenuCell.self, forCellWithReuseIdentifier:"menuCell")
注册 Nib
var nib=UINib(nibName: "MenuCell", bundle:nil)
collectionView.registerNib(nib, forCellWithReuseIdentifier: "menuCell")
你能从中得到帮助吗
关于ios - UICollectionElementKindCell 的 registerNib 在使用 presentViewController 动画时不起作用 : false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31308666/