如何从一个视图切换到另一个视图? [英] How to switch from one view to another?

查看:171
本文介绍了如何从一个视图切换到另一个视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于窗口的应用程序。在这种类型的应用程序中从一个视图切换到另一个视图的最简单方法是什么?

I have a window based application. What is the simplest way to switch from one view to another in this type of application?

推荐答案

如果您没有使用导航控制器,并且不需要切换到不同的视图控制器,那么这样的东西只会切换视图:

If you aren't using a navigation controller, and don't need to switch to a different view controller, then something like this will just switch views:

[ myCurrentTopView removeFromSuperView ];

[ window addSubView: myNewView ];

为此,您需要引用当前的顶视图(上例中的myCurrentTopView),并且可能希望事先确保你的myNewView对象被分配,初始化,正确的帧大小等。

For this, you will need a reference to the current top view (myCurrentTopView in the above example), and might want to make sure your myNewView object is allocated, initialized, the proper frame size, etc. beforehand.

这篇关于如何从一个视图切换到另一个视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆