gpt4 book ai didi

iphone - 如何将 UIViewController 作为 subview 添加到 UIViewController(RootViewController)?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:15:10 25 4
gpt4 key购买 nike

我有一个名为 LoginViewControllerUIViewController,它是 AppDelegate 中的一个 rootViewController。在 LoginViewController 中,我有两个按钮:LoginEnroll

当我点击 Login 时,我将 TabBarController 指定为 rootViewController,然后显示 TabBarController。但是,现在我认为我需要在点击 Enroll 时添加另一个 UIViewcController 作为 subview 。我尝试了以下方法:

[self.view addsubview:viewcontroller.view];

但这里的问题是我的 ViewController 的 view.top 固定在屏幕顶部下方约 20 像素处。我认为状态栏有问题,但我不知道如何解决。

我认为我需要将我的 ViewController 作为 subview 添加到 LoginViewController,然后从那里重定向到不同的 View 。有人可以建议其他选择吗?

最佳答案

尝试将框架设置为您的注册屏幕对象,然后将其作为 subview 添加到登录 View 。例如:

[enrollViewcontroller.view setFrame:CGRectMake(0,0,320,440)];
[self.view addsubview:enrollViewcontroller.view];

关于iphone - 如何将 UIViewController 作为 subview 添加到 UIViewController(RootViewController)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11087897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com