salari mameri
salari mameri

Reputation: 228

Present view controller from another storyboard

index.swift

func didReceiveNewSession(_ session: QBRTCSession, userInfo: [String : String]? = nil) {
    print("Receive")
    let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let goController = mainStoryboard.instantiateViewController(withIdentifier: "call") as! call
    self.present(goController, animated: true)
}

If I'm in index.swift and I receive session, print Receive for me and go to call.swift.

But if after load index.swift I go to page.swift, if receive session, print Receive but don't go to call.swift and stay on page.swift.

I want if I'm anywhere after present, go to call.swift

Upvotes: 0

Views: 2956

Answers (1)

ndreisg
ndreisg

Reputation: 1179

  • Open your first Storyboard and create a Storyboard Reference enter image description here

  • Enter the name of your second Storyboard in the "Storyboard" property and the Reference ID of the destination ViewController in the "Reference ID" property of your newly crated reference. (Reference ID is equivalent to Storyboard ID of the destination ViewController)

    enter image description here

  • Create a segue from your source ViewController to the newly created Storyboard Reference. Make sure the segue has an Identifier.

  • In your code perform the segue like this

.

func didReceiveNewSession(_ session: QBRTCSession, userInfo: [String : String]? = nil) {
    print("Receive")
    self.performSegue(withIdentifier: "mySegue", sender: self)
}

Credits to https://stackoverflow.com/a/33753164/7990095

Upvotes: 2

Related Questions