tabBarController popToRooTViewControler

发布于 2024-08-27 06:17:04 字数 339 浏览 4 评论 0原文

每次用户更改选项卡时,对于所选选项卡,我想将其推送到其顶级控制器。我已经为 Tabbarcontroller 实现了委托方法,如下所示:

- (void) tabBarControler:(UITabBarController *)tabBarController didSelectViewController:(UIViewController*)viewController{
    [[self navigationController] popToRootViewController Animated:NO];  
}  

这似乎不起作用,但我可以确认每次更改选项卡时都会调用该方法

Every time a user changes a tab, for the selected tab I want to push it to its top level controller. I have implemented the delegate method for the Tabbarcontroller like this:

- (void) tabBarControler:(UITabBarController *)tabBarController didSelectViewController:(UIViewController*)viewController{
    [[self navigationController] popToRootViewController Animated:NO];  
}  

This does nto seem to work but I can confirm the method is being called every time I change tabs

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

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

发布评论

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

评论(1

澜川若宁 2024-09-03 06:17:04

根据您的代码,它看起来像是一个简单的拼写错误。正确的方法是 [[self navigationController] popToRootViewControllerAnimated:NO] (你有一个额外的空间)。此外,tabBarController 拼写错误,这会阻止调用该方法。

如果这不起作用,则 [self navigationController] 可能是错误的(取决于您从何处调用该方法)。如果您从 AppDelegate 调用,它可能应该类似于 [tabBarController.selectedViewController.navigationController popToRootViewControllerAnimated:NO]。希望有帮助。

Based on your code, it looks like a simple misspelling. The correct method is [[self navigationController] popToRootViewControllerAnimated:NO] (you had an extra space). Also, tabBarController is misspelled, which would prevent the method from being called.

If that doesn't work, it's possible that [self navigationController] might be wrong (depending on where you're calling the method from). If you're calling from your AppDelegate, it should probably be something like [tabBarController.selectedViewController.navigationController popToRootViewControllerAnimated:NO]. Hope that helps.

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