我的应用程序的故事板使用UIViewController来转到应用程序的不同视图。 但是,我想尝试第三方库,即EGOPhotoViewer,而不是重新发明轮子。 但是如何从故事板中将UINavigationController添加到UIViewController? 以下是此库用于初始化的代码。
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source]; [self.navigationController pushViewController:photoController animated:YES]当我将它添加为视图控制器时,它只适用于我:
[self presentModalViewController:photoController animated:YES];但是该库在导航控制器中效果最好,因为我的测试方法中缺少标题栏和导航按钮。
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.
最满意答案
在故事板中
选择你原来的viewController,然后在菜单中:
编辑器 - >嵌入 - >导航控制器(即viewController成为rootViewController)
现在您有各种选项来推送您的photoController,例如:
从rootViewController中的UI小部件,CTRL-拖动到photoController。 这将创建一个segue,它应该可以在没有额外代码的情况下工作(虽然它有助于命名segue,以便稍后可以在代码中引用它)
或者你在问题中的代码。
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.
更多推荐
发布评论