performSegue 被调用但实际上没有转到 VC2? (Swift 3.0)

performSegue being called but not actually segueing to VC2? (Swift 3.0)

谁能发现我的错误?左栏按钮可以关闭,但是操作按钮调用 performSegue 但 UI 不会更改 VC?在 ViewDidLoad 中调用 showLinkPreviewController 有效,所以显然这是 target/action 的问题?错误?

     let button = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissTimeline))
            timelineViewController.navigationItem.leftBarButtonItem = button

            let previewButton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(showLinkPreviewViewController))
            timelineViewController.navigationItem.rightBarButtonItem = previewButton

            // Create a navigation controller to hold the
            let navigationController = UINavigationController(rootViewController: timelineViewController)
            showDetailViewController(navigationController, sender: self)
        }
        func dismissTimeline() {
            dismiss(animated: true, completion: nil)
        }

        func showLinkPreviewViewController() {
            self.performSegue(withIdentifier: "showLinkPreviewViewController", sender: self)
        }

  // Create a navigation controller to hold the
        let navigationController = UINavigationController(rootViewController: timelineViewController)
        showDetailViewController(navigationController, sender: self)

你应该像这样使用 dispatch -

dispatch_async(dispatch_get_main_queue(), ^{
    [self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"thirdScreen"] animated:YES];
});

或其他方式 -

dispatch_async(dispatch_get_main_queue(), ^{
   func showLinkPreviewViewController() {
            self.performSegue(withIdentifier: "showLinkPreviewViewController", sender: self)
        }

});

明白了,正在执行 segue,但由于我没有将当前 VC 从堆栈中删除,所以我看不到它:

修复:

  func showLinkPreviewViewController() {
        dismiss(animated: true, completion: nil)
        self.performSegue(withIdentifier: "showLinkPreviewViewController", sender: self)
    }