如何在其他Storyboard中的vc中使用委托在MainStoryboard中显示ViewController?

时间:2018-10-26 10:20:31

标签: ios swift uiviewcontroller delegates storyboard

我有2个故事板:MainStoryboardLoginStoryboard。我想在2个故事板上的LoginViewController中使用委托。当我点击LoginViewController中的“登录”按钮时,我想呼叫代表并在UIViewController中显示名为main.storyboard的特定ProfileViewController

这是我的课程:

LoginDelegate.swift->委托

LoginViewController.swift->它是LoginStoryboard中的初始vc

HomeViewController.swift->它是MainStoryboard中的初始vc

ProfileViewController.swift->这是MainStoryBoard中的vc,接下来我要显示我点击“登录”按钮

你能帮我吗?

2 个答案:

答案 0 :(得分:0)

您必须像这样在您的Failed to load https://accounts.google.com/o/oauth2/token: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. 中放置一个Storyboard Reference

enter image description here

然后,引用您的Login.storyboard

enter image description here

答案 1 :(得分:0)

您必须在“登录按钮操作”中调用以下行:

let kMainStoryBoard = UIStoryboard.init(name: "Main", bundle: nil)
if let profileVC = kMainStoryBoard.instantiateViewController(withIdentifier: "your profile VC storyboard identifier") as? ProfileViewController {
        let navigation = UINavigationController(rootViewController: profileVC)
        self.present(navigation, animated: true, completion: nil)
    }