代码之家  ›  专栏  ›  技术社区  ›  thelearner

自定义segue崩溃应用程序-“不建议在分离的视图控制器上显示视图控制器”

  •  0
  • thelearner  · 技术社区  · 8 年前

    首先,我知道有几十个问题与我的错误信息相同。然而,我的问题的背景完全不同,所以我无法用前面的StackOverflow问题来解决它。

    我创建了一个自定义Segue,昨天一切正常。 今天,我进一步修改了我的应用程序,没有,我的应用程序突然停止工作了。

    我的应用程序崩溃,出现以下eror消息

    在分离的视图控制器上显示视图控制器是 不鼓励-AppName。主导航控制器:0x7ff19f054a00。

    崩溃点是: sourceViewController.present(destinationViewController, animated: false, completion: nil)

    今天修改应用程序后,我有以下控制器层次结构
    VC:A->u导航控制器:B-导航控制器的根控制器:C->*使用此自定义序列*VC:D

    ->:表示序列。此序列由C组成,C是导航控制器的根控制器

    这真的很奇怪,因为一切都很顺利,现在我遇到了这次车祸。

    这是我的自定义序列的执行方法:

           override func perform() {
    
    
        //.... custom segue animation......
        //.....
    
            UIView.animate(withDuration: DURATION, animations: {
    
    // Some more animations
                self.bubble.transform = CGAffineTransform.identity
                destinationView?.transform = CGAffineTransform.identity
                destinationView?.alpha = 1
                destinationView?.center = sourceCenter!
                destinationView?.layer.cornerRadius = 1
    
    
            }, completion: { (_) in
    
                self.bubble.isHidden = true
                destinationView?.clipsToBounds = defaultClipsToBoundsSettings!
    
                //finally showing it
                DispatchQueue.main.async
                    {
    //********* THIS IS THE CRASH POINT
                     sourceViewController.present(destinationViewController, animated: false, completion: nil)
    
    
                }
    
            })
    
    
    
        }
    

    在这里,我正在执行按钮操作方法的步骤:

    castedRootController.performSegue(withIdentifier: "ViewShare", sender: nil)
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   Shehata Gamal    8 年前

    分段应在VC A和navigationController B之间,因为VC C被视为导航的根VC,并且在分段期间VC A不显示navigationController

    推荐文章