swift -> 不同target 之间 的跳转

 


swift -> 不同target 之间 的跳转
 

 

 

方式一,推荐

其中 ViewController() 是另外一个target的View, 也需要如上图 对 "Target Membership" 进行设置。

 

self.present(ViewController(), animated: true, completion: nil)

 

 

            self.parent?.present(ViewController(), animated: true, completion: nil);
            //self.navigationController?.pushViewController(ViewController(), animated: true)

 

 

 

 

方式二 

 

 

然后 执行 通常的跳转 代码 

 

            let mainStoryBorad = UIStoryboard(name: "要跳转到的storyboard的文件名比如Main", bundle: nil);
            let vc : UIViewController = mainStoryBorad.instantiateViewController(withIdentifier: "要跳转的viewcontroller对应的view的storyboard ID") as UIViewController;
            
            //设置跳转动画效果
            
            vc.modalTransitionStyle = UIModalTransitionStyle.flipHorizontal;
            
            present(vc, animated: true, completion: nil);