视图控制器 IOS 在视图之间切换
我是 ios 编程新手,我需要一些帮助,无法弄清楚如何在不触发按钮事件的情况下在两个视图之间切换
我有一个闪屏等待 2 秒,然后它应该进入主视图。我不知道如何获取主视图的引用并导航到主视图!
有关于以编程方式在视图之间切换的教程吗?
感谢您的帮助。 干杯
I am new at ios programming and I need some help, can't figure out how I am going to switch between two views without firing a button event
I have a splash screen waits for 2 sec then it should go to main view. I don't know how I am going to acquire the main view's reference and navigate to main view!
Any tutorial about switching between views programmatically?
Thanks for your help.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于启动屏幕,您必须将其命名为 Default.png,并且在 appDelegate didFinishlaunchingMethod 中,您必须将视图控制器添加到窗口。 Default.png 会自动引用为初始屏幕。尝试一下
For Splash screen you have to name it Default.png and in appDelegate didFinishlaunchingMethod, you have to add view controller to window. the Default.png is automatically reference as a splash screen. try it out
从 Xcode 默认项目之一开始,看看它们是如何设置的。他们应该给你一个窗口,可以看到开箱即用的主视图。
如果将 Default.png 图像文件添加到项目中,它将自动用作启动画面并在启动时显示。然而,它在 2 秒内不可见,而是在应用程序启动时才可见。
如果您希望它显示更长时间,则必须将具有相同 png 图像的 UIImageView 添加到您的主视图中,然后在两秒后将其从主视图中删除。
可以使用performSelector:withObject:afterDelay在一段时间后触发UIImageView的隐藏。然而,这违背了苹果的设计指南,因为闪屏只是为了让用户在应用程序启动之前查看。
至于添加新视图,我建议使用 UINavigationViewController。使用此功能可以让您导航回主视图,并且您还可以获得一个漂亮的动画作为视图之间的过渡。
Start with one of Xcodes default projects, and see how they are setup. They should give you a window, with a main view out of the box.
If you add a Default.png image file to your project, it will automatically be used as a splash screen and displayed upon startup. However it will not be visible for 2 seconds, but rather as long as it takes for the application to start.
If you want it to be displayed longer, you will have to add a UIImageView with the same png image to your mainview, then remove this from your mainview after two seconds.
You can use performSelector:withObject:afterDelay to trigger the hiding of the UIImageView after a period of time. However this goes against Apples design guide, as the splash screen only is meant as a ting for the user to look upon before the application launches.
As for adding new views, I recommend using a UINavigationViewController. Using this enables you to navigate back to the main view, and you also get a nice animation as a transition between the views.
如果您想在使用
addSubview
的视图之间切换,也许本教程会有所帮助 ->教程
If you want to switch between views you use
addSubview
maybe this tutorial will help ->Tutorial