选择 tabBarController 的索引并传递数据
我想在向其传递数据时选择 tabbarcontroller 索引 0 处的 UIViewController。看来我正在访问 UINavigationController。有谁知道为什么会出现这种情况?
SearchViewController *search = (SearchViewController *)[self.tabBarController.viewControllers objectAtIndex:0];
[search initWithText:@"This is a test"];
[[self.tabBarController.viewControllers objectAtIndex:1] pushViewController:search animated:NO];
// 还可以使用以下方法接收错误:
self.tabBarController.selectedViewController = search;
Error:
-[UINavigationController initWithText:]: unrecognized selector sent to instance
I want to select the UIViewController at index 0 of my tabbarcontroller while passing data to it. It seems I am accessing the UINavigationController instead. Anyone know why this occurs?
SearchViewController *search = (SearchViewController *)[self.tabBarController.viewControllers objectAtIndex:0];
[search initWithText:@"This is a test"];
[[self.tabBarController.viewControllers objectAtIndex:1] pushViewController:search animated:NO];
// Also receive the error using this:
self.tabBarController.selectedViewController = search;
Error:
-[UINavigationController initWithText:]: unrecognized selector sent to instance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哇,现在我觉得自己很傻。这有效。
Wow, now I feel silly. This worked.