如何在没有NavigationController的情况下推送子ViewController?
我想将 viewController 推送到我的主 viewController 上的一个区域。据我了解,除非将 NavigationController 添加到 UIWindow 中,否则无法使用它。
这个动画让人想起 UIScrollView 水平滚动。但我希望它像导航控制器一样工作。当用户按下特定操作时,视图控制器将发生变化。
ViewController2 将是一个带有一些其他按钮的 tableView。
ViewController3 将是一个从 tableView 更改对象的表单。
I want to push viewControllers to an area on my main viewController. From what I understand, you can't use a NavigationController unless you are adding it to a UIWindow.
This animation reminds of UIScrollView horizontal scrolling. But I want it to work like a NavigationController instead. The ViewControllers will be changed when the user presses on specific actions.
ViewController2 is going to be a tableView with some other buttons.
ViewController3 is going to be a form to change the object from the tableView.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我最近在 UIView 中发现了一种方法,可以在切换视图时产生“推或弹出”的感觉。
这是直接来自 UIView 文档的,所以我建议查看 UIView 类参考 查看具体内容。基本上,它将一个视图切换到另一个视图,而
options:
部分允许您从多种不同的样式中进行选择。I recently found a method in UIView that creates a "push or pop" feel to switching views.
This is straight out of the UIView documentation, so I would recommend looking at the UIView Class Reference to see the specifics. Basically, it switches a view to another view, while the
options:
section lets you pick from a multitude of different styles.我实际上通过使用 UIView 动画解决了这个问题。
并使用它
请记住,您已经分配了一个 UIViewController,当您使用完它时需要释放它!在示例中,我完成了 loginController 并释放了它。
I Actually solved it by playing around with UIView Animations.
and to use it
Remeber that you have alloced a UIViewController that you need to release when you are done useing it! In example i'm done with loginController and releasing it.
如果没有
UINavigationController
,绝对无法本地“推送”任何控制器。但是,您可以对视图进行动画进出。根据您发布的示例,简单的
UIScrollView
看起来将是您最简单的选择。There's absolutely no way to "push" natively any controller without a
UINavigationController
. You can however, animate views in and out.With the example you have posted, it looks like a simple
UIScrollView
would be your easiest option.我会使用 UIScrollView,因为它能够捕捉到内置的“页面”。您也可以使用 setContentOffset:animated: 滚动到任何部分。
I’d use a UIScrollView, as it has the ability to do snapping to "pages" built in. You can also scroll to any part with setContentOffset:animated: as well.