0
fileprivate func showGroupProfile(_ item:HomescreenLongTapItem) {
    let vc = storyboard?.instantiateViewController(withIdentifier: "GroupProfileViewController") as! GroupProfileViewController
    present(vc, animated: true, completion: nil)
}

I need to change VC after press on icon in HomescreenLongTap but I recive that error 'Storyboard () doesn't contain a view controller with identifier 'GroupProfileViewController' I used the StoryboardID in my code. How can I correctly navigate to next ViewController?

fillsondy
  • 15
  • 4
  • 1
    Try [this](https://stackoverflow.com/a/48612127/2395636). – Kamran Mar 17 '20 at 09:05
  • I am voting to close this question as I asked the same question about 9 years ago. A simple google search would have found the right answer. – Mat Mar 17 '20 at 10:07

2 Answers2

0

Try like this:

    if let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(identifier: "GroupProfileViewController") as? GroupProfileViewController {
         present(vc, animated: true, completion: nil)
    }

in storyboard: --> in custom class give this viewcontroller class GroupProfileViewController

--> identity --> Storyboard ID (GroupProfileViewController) also give same name as class or your wish.

Gowri G
  • 420
  • 4
  • 18
0
  1. Make sure you set the identifier of the viewcontroller, lets say "GroupProfileViewController"
  2. Make sure this code is NOT in viewDidLoad(). If you have, consider doing this in viewDidAppear()

Present the code like this example:

if let storyboard = storyboard{
   let vc = storyboard.instantiateViewController(withIdentifier: "GroupProfileViewController") as! GroupProfileViewController
   self.present(vc, animated: true)
}
Putte
  • 526
  • 1
  • 6
  • 15