什么是错误“应用程序尝试在目标上推送零视图控制器。”?

发布于 2024-10-19 13:27:16 字数 1249 浏览 1 评论 0原文

我的编码是

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

FirstTabBarItem = [[FirstMuseum alloc] init];
SecondTabBarItem = [[SecondMaps alloc] init];
ThirdTabBarItem = [[ThirdExhibition alloc] init];
FourthTabBarItem = [[FourthTabBarItem alloc] init];


first = [[UINavigationController alloc] initWithRootViewController:FirstTabBarItem];
second = [[UINavigationController alloc] initWithRootViewController:SecondTabBarItem];
third = [[UINavigationController alloc] initWithRootViewController:ThirdTabBarItem];
fourth = [[UINavigationController alloc] initWithRootViewController:FourthTabBarItem];


first.title = @"Hello";
second.title = @"Hello";
third.title = @"Hello";
fourth.title = @"Hello";

myControllerArray = [[NSMutableArray alloc] init];

[myControllerArray addObject:first];
[myControllerArray addObject:second];
[myControllerArray addObject:third];
[myControllerArray addObject:fourth];


myTabBar = [[UITabBarController alloc] init];

[myTabBar setViewControllers:myControllerArray];

localNavigationController = [[UINavigationController alloc] initWithRootViewController:myTabBar];

NSLog(@"Hello, You Tapped !");  }

什么错误, 我正在尝试制作一个包含四个项目的 UITabBarController,所以现在我应该做什么 ????

my coding is

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

FirstTabBarItem = [[FirstMuseum alloc] init];
SecondTabBarItem = [[SecondMaps alloc] init];
ThirdTabBarItem = [[ThirdExhibition alloc] init];
FourthTabBarItem = [[FourthTabBarItem alloc] init];


first = [[UINavigationController alloc] initWithRootViewController:FirstTabBarItem];
second = [[UINavigationController alloc] initWithRootViewController:SecondTabBarItem];
third = [[UINavigationController alloc] initWithRootViewController:ThirdTabBarItem];
fourth = [[UINavigationController alloc] initWithRootViewController:FourthTabBarItem];


first.title = @"Hello";
second.title = @"Hello";
third.title = @"Hello";
fourth.title = @"Hello";

myControllerArray = [[NSMutableArray alloc] init];

[myControllerArray addObject:first];
[myControllerArray addObject:second];
[myControllerArray addObject:third];
[myControllerArray addObject:fourth];


myTabBar = [[UITabBarController alloc] init];

[myTabBar setViewControllers:myControllerArray];

localNavigationController = [[UINavigationController alloc] initWithRootViewController:myTabBar];

NSLog(@"Hello, You Tapped !");  }

what is error,
I am trying to make a UITabBarController with four item, so now what should I do
??????

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

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

发布评论

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

评论(2

著墨染雨君画夕 2024-10-26 13:27:16

这意味着您尝试推送的视图控制器尚未正确分配。请检查视图控制器的分配情况,看看它是否分配干净

It means the view controller u r trying to push has not been allocated properly. Pls check the allocation of the view controller and see if its allocated cleanly

遮了一弯 2024-10-26 13:27:16

是的,你可能忘记分配视图控制器,所以试试我的代码:

按钮操作

_forgotviewcontroller means my second view property eg:

@property (nonatomic,strong) ForgotPassword *forgotviewController;

1)tapaction意味着在我的第一个视图中声明的

-(void) tapAction:(id)sender
{
    _forgotviewController=[[ForgotPassword alloc]init];
    [self.navigationController pushViewController:self.forgotviewController animated:YES];
}

尝试这个你会得到导航

yes you can forgot to allocate view controller so try my code:

1) tapaction means button action

_forgotviewcontroller means my second view property eg:

@property (nonatomic,strong) ForgotPassword *forgotviewController;

declared in my firstview

-(void) tapAction:(id)sender
{
    _forgotviewController=[[ForgotPassword alloc]init];
    [self.navigationController pushViewController:self.forgotviewController animated:YES];
}

try this you wil get the navigation

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