我有一个在 中定义的弹出框UIViewController
,但现在需要从自定义中呈现UICollectionViewCell
。present
不再工作,因为该类是一个并且UICollectionViewCell
不再是 UIViewController。如何呈现自定义的弹出框UICollectionViewCell
。
@IBAction func period(_ sender: Any) {
let storyboard = UIStoryboard(name: "ScoreClockPopoverViewController", bundle: nil)
let scoreClockPopoverViewController = storyboard.instantiateViewController(withIdentifier: "ScoreClockPopoverViewController") as! ScoreClockPopoverViewController
scoreClockPopoverViewController.modalPresentationStyle = .popover
let popover = scoreClockPopoverViewController.popoverPresentationController!
popover.delegate = self
popover.permittedArrowDirections = .any
popover.sourceView = periodButton
popover.sourceRect = periodButton.bounds
present(scoreClockPopoverViewController, animated: true, completion:nil)
//Error: Use of unresolved identifier 'present'
}
如果我尝试扩展UICollectionViewCell
as a UIViewContoller
,则会收到以下错误:Extension of type 'HeaderCollectionViewCell' cannot inherit from class 'UIViewController'