Vad
Vad

Reputation: 3740

Pushing UINavigationController into UIViewController Using Storyboard

My app's storyboard is using UIViewController's to go to different views of the app. However, I want to try a third party library, that is EGOPhotoViewer, not to reinvent the wheel. But how do I add UINavigationController to UIViewController from the storyboard? Here is the code this library is using to initialize.

EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];

[self.navigationController pushViewController:photoController animated:YES]

It only works for me when I add it as a view controller:

[self presentModalViewController:photoController animated:YES];

but the library works best within navigation controller because title bars and navigation buttons are missing from my testing approach.

Upvotes: 1

Views: 3315

Answers (1)

foundry
foundry

Reputation: 31745

In the storyboard

  • select your original viewController, then in the menu:

  • Editor -> embed in -> Navigation Controller (that viewController becomes the rootViewController)

Now you have various options to push your photoController eg:

  • From a UI widget in your rootViewController, CTRL-drag to photoController. That will create a segue which should work without extra code (although it helps to name the segue so that you can refer to it later in code)

  • or in code as you have in the question.

Upvotes: 4

Related Questions