Ariel Gemilang
Ariel Gemilang

Reputation: 791

cannot instantiante and push to another view controller

i have collection view and if cell selected, it downloading a pdf file. After download completed and select the cell again, it push to another view controller. But it doesnt push, can someone explain why?

here's my code

if self.percentProgressFinal == 1.0 { //download complete
     print("SUCCESS")
     let storyboard = UIStoryboard(name: "Main", bundle: nil)
     let vc = storyboard.instantiateViewControllerWithIdentifier("NEXT")
      self.navigationController?.pushViewController(vc, animated: true)
} else {
      print("still downloading")
}

It successful printing "SUCCESS" but the code wont execute. I Also try use present and this

    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let nextViewController: redirectMagazineViewController = storyBoard.instantiateViewControllerWithIdentifier("NEXT") as! redirectMagazineViewController // my second view controller name   
    self.navigationController?.pushViewController(nextViewController, animated: true)

and still doesnt work. I'm sure my storyboard id is "NEXT".

Upvotes: 1

Views: 1001

Answers (2)

Willjay
Willjay

Reputation: 6459

Seems like you don't have navigation controller embedded.

enter image description here

Upvotes: 1

Lukl
Lukl

Reputation: 41

Did you check the button " use storyboard id" on your Identity Inspector view controller?

Upvotes: 0

Related Questions