Is the view controller from which you are calling this code embedded in the Navigation Controller
? If it's not, then nothing would happen when you call pushViewController
method.
Go to your Storyboard
, select the initial view controller, then from the top bar Editor > Embed in > Navigation Controller and try again.