tabBarController popToRooTViewControler
每次用户更改选项卡时,对于所选选项卡,我想将其推送到其顶级控制器。我已经为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的代码,它看起来像是一个简单的拼写错误。正确的方法是
[[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.