0
私は、私の迅速なコードで3D Touch PeekとPopを実装しようとしています。ユーザーがピークビューで深く押すと、プレビューアクションの配列(共有、更新、削除)が表示されます。3D Peek and POP in swift
私が必要とするのは、ユーザーがUpdateアクションを選択すると、UpdateViewコントローラーに移動しますが、クラッシュすることがあります。ここで
は私のコードです:私は画面を更新するために移動するだけでなく、このコードを試してみましたHomePeakViewController.swift
let item3 = UIPreviewAction(title: "Update", style: .Default) { (action:UIPreviewAction, vc:UIViewController) -> Void in
print("Update")
let nb:BookAppointmentViewController = BookAppointmentViewController(nibName: "BookAppointmentViewController", bundle: nil)
let root = UIApplication.sharedApplication().keyWindow?.rootViewController
root?.presentViewController(nb, animated: true, completion: nil)
POP方法HomeViewController.swift
func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
let Homepeak = HomePeakViewController()
showViewController(Homepeak, sender: self)
}
で、それ私には(致命的なエラー:予期せず、オプション値をアンラッピングしながらnilが見つかりました)。
var top = UIApplication.sharedApplication().keyWindow?.rootViewController
let test = AppointmentDetailsViewController()
top!.presentViewController(test, animated: true, completion: {})
あなたの努力は大変ありがたいです。