Meine App ist abgestürzt ist, wenn ich versucheApp abgestürzt aufgrund UICollectionViewController nicht presentingViewController
Gewohnheit UIPresentationController von UICollectionViewController zu nennen@IBAction func showSettingsMenu(sender: UIBarButtonItem) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let mvc = storyboard.instantiateViewControllerWithIdentifier(Constants.SettingsViewControllerId) as? SettingsViewController {
mvc.modalPresentationStyle = .Custom
mvc.transitioningDelegate = self
presentViewController(mvc, animated: true, completion: nil)
}
}
hier ist meine Gewohnheit Presentation View Controller:
class SpecialSizePresentationController: UIPresentationController {
override func frameOfPresentedViewInContainerView() -> CGRect {
guard let height = containerView?.bounds.height else {
return CGRectZero
}
guard let width = containerView?.bounds.width else {
return CGRectZero
}
let y = height * 0.6
let frameHeight = height * 0.4
return CGRectMake(8, y - 8 , width - 8 - 8 , frameHeight)
}
}
Hier ist UIViewControllerTransitioningDelegate Protokollimplementierung in meinem UICollectionViewController:
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
return SpecialSizePresentationController(presentedViewController: presented, presentingViewController: presenting)
}
und App im Gegenzug Ort mit Fehler (Null ist aufgrund präsentierenden) abgestürzt ist:
fatal error: unexpectedly found nil while unwrapping an Optional value
Ist es möglich, individuelle Präsentation Controller von UICollectionViewController zu präsentieren?
Wie kann es implementiert werden?