只要在有PreViewAction 的ViewController中加入

weak var previousViewController: UIViewController?

然後在在前一頁prepareForSegue或是3DTouch的Delegate中對有PreviewAction的ViewController設定

nextViewController.previousViewController = self

就能夠使用 previousViewController、pushViewController、showViewController,解決沒有作用的問題

 

  override func previewActionItems() -> [UIPreviewActionItem] {

        

        let shareAction = UIPreviewAction(title: "Share", style: .Default) { [unowned self] (action, viewController) in

            print("\(action): \(viewController))")

            

            let alert = UIAlertController(title: "訊息", message: "分享", preferredStyle: .Alert)

            alert.addAction(UIAlertAction(title: "確認", style: .Default, handler: nil))

            self.previousViewController?.presentViewController(alert, animated: true, completion: nil)

        }

        

        return [shareAction, ]

    }

 

 

參考資料:

https://www.youtube.com/watch?v=bziKrxhJQII&ebc=ANyPxKopNEt4ykYuTHrxXBLWxvHivuy2hOfEWrrsOBxNu9nSb2YcuO5XFzUp7PHU9YbM_deO7hR1lnEKFlPE-bZEQxDpYaMMKA&nohtml5=False

arrow
arrow
    全站熱搜

    小賢 發表在 痞客邦 留言(0) 人氣()