如何在主视图之前显示次要视图?

发布于 2024-10-01 12:23:15 字数 104 浏览 0 评论 0原文

我想让我的应用程序(在启动时)加载我在原始视图顶部创建的视图,然后当单击按钮时,顶部视图将消失并显示下面的主视图。我知道这非常简单,但我该怎么做呢?也许将视图推送到 viewDidLoad 中?

I'm wanting to have my app (on launch) load a view that I have created over the top of the original view, then when a button is clicked the top view will disappear and show the main view underneath. I know this is terribly simple, but how would I do this? Maybe push the view in viewDidLoad?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若水微香 2024-10-08 12:23:15

使用导航控制器

MyViewController *myView = [[MyViewController alloc] init];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:myView];
My2ndView *secondView = ....
[navControl pushViewController:secondView animated:NO];
[window addSubView:navControl.view]

Use a navigation controller

MyViewController *myView = [[MyViewController alloc] init];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:myView];
My2ndView *secondView = ....
[navControl pushViewController:secondView animated:NO];
[window addSubView:navControl.view]
多孤肩上扛 2024-10-08 12:23:15

这可能非常简单。当用户单击按钮时,只需执行此操作

secondViewController.view.hidden = YES;

只需在委托中添加两个视图,然后在委托中执行此操作。

如果您愿意,只需在“第二个ViewController”中执行即可! self.view.hidden = YES;

听起来你只是在做一些简单的事情……不需要费心使用视图控制器。

您问如何显示第二个视图,就像这样..

-(BOOL)application:(UIApplication *)applic`ation
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
        [window addSubview:yourMainView.view];
        [window addSubview:theTemporaryView.view]; // it goes on top

        [window makeKeyAndVisible];

        application.idleTimerDisabled = YES;
        return YES;
        }
-(BOOL)eliminateTempView // example, when the user clicks on the button
        {
        theTemporaryView.view.hidden = YES;
        [theTemporaryView release];
        }

希望它有帮助!

This can be incredibly simple. When the user clicks the button, just do this

secondViewController.view.hidden = YES;

Just add the two views in your delegate, and do that in your delegate.

If you prefer, just do it "in" secondViewController! self.view.hidden = YES;

It sounds like you're just doing something simple ...... no need to bother with a view controller.

You ask how to display the second view, just like this ..

-(BOOL)application:(UIApplication *)applic`ation
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
        [window addSubview:yourMainView.view];
        [window addSubview:theTemporaryView.view]; // it goes on top

        [window makeKeyAndVisible];

        application.idleTimerDisabled = YES;
        return YES;
        }
-(BOOL)eliminateTempView // example, when the user clicks on the button
        {
        theTemporaryView.view.hidden = YES;
        [theTemporaryView release];
        }

Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文