skip to Main Content
let storyboardBundle = Bundle(identifier: "SignUPFramework")

let vc = UIStoryboard.init(name: "SignIn", bundle: storyboardBundle).instantiateViewController(withIdentifier: "SignInViewcontroller") as! SignInViewcontroller
navigationController?.pushViewController(vc, animated: true)

I have navigated to storyboard of framework as above.

3

Answers


  1. Chosen as BEST ANSWER

    I have solved it by

     let bundle = Bundle(for: SignInViewcontroller.self)
     let vc = UIStoryboard.init(name: "SignIn", bundle: bundle).instantiateViewController(withIdentifier: "SignInViewcontroller") as! SignInViewcontroller
    

    in above snippet instead of passing bundle id i have passed viewcontroller itself.


  2. You own the navigationController. So you can use either popViewController(animated:) (if you are sure that there is only one view controller you wish to pop), or popToViewController(_:animated:), or popToRootViewController(animated:) (if you wish to return to the root).

    It does not matter that the storyboard is in a framework. You still own the view hierarchy, the navigation stack and the view controller instance you get from the below line of code

    let vc = UIStoryboard.init(name: "SignIn", bundle: storyboardBundle).instantiateViewController(withIdentifier: "SignInViewcontroller") as! SignInViewcontroller
    

    So you can do whatever you want with it in terms of navigation (push it and pop it or present it and dismiss it).
    You just need to identify at what point you want to trigger any of these actions.

    Login or Signup to reply.
  3. I think you are using xib so it will not return action first you should do protocol for callback to view controller then you can use popViewController(animated:).

    protocol CallBackDelegate: AnyObject {
        func back()
    }
    
    //Delegate
    weak var delegate:CallBackDelegate?
    
    @IBAction func buttonAction(_ sender: Any) {
            delegate?.back()
    }
    

    Now you can use protocol in view controller

    class ViewController: UIViewController, CallBackDelegate {
      func back() {
            navigationController?.popViewController(animated: true)
        }
    }
    

    Note :- Confirm delegate variable in cellForRowAtIndexPath i.e.

    cell.delegate = self
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search