gpt4 book ai didi

iphone - 屏幕上的多个 ViewController

转载 作者:行者123 更新时间:2023-11-28 22:47:55 26 4
gpt4 key购买 nike

我想在一个窗口上放置两个 UIViewController(如下所示)。是否可以将其设置为每个 View 分别由其自己的 Controller 控制? enter image description here

在应用委托(delegate)中,我通过以下方式添加 subview

TabBarViewController *tabBarVC = [[TabBarViewController alloc] init];
CGRect frame = tabBarVC.view.frame;
frame.origin.y = self.window.bounds.size.height - frame.size.height;
tabBarVC.view.frame = frame;
[self.window insertSubview:tabBarVC.view aboveSubview:tabVC.view];

它加载了,但是当我点击一个按钮(IBAction),或者做任何需要 Controller 的事情时,应用程序崩溃了。我做错了什么?

谢谢!

最佳答案

为 tabBarVC 的 iVar 或属性创建强引用并更改此行:

TabBarViewController *tabBarVC = [[TabBarViewController alloc] init];

收件人:

tabBarVC = [[TabBarViewController alloc] init];

或者

self.tabBarVC = [[TabBarViewController alloc] init];

关于iphone - 屏幕上的多个 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12722098/

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