使用Storyboard将UINavigationController推送到UIViewController(Pushing UINavigationController into UIViewCon

编程入门 行业动态 更新时间:2024-10-23 21:25:57
使用Storyboard将UINavigationController推送到UIViewController(Pushing UINavigationController into UIViewController Using Storyboard)

我的应用程序的故事板使用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.

更多推荐

本文发布于:2023-08-07 11:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UINavigationController   Storyboard   Pushing   UIViewController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!