1
votes

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.

1
Why do you want storyboard. This approach is more straightforward.ipinak
I do not want to rewrite library which works with nav controllers. I would use any best approach that works with my storeyboarded appVad

1 Answers

4
votes

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.