如何使第3步事件崩溃或将其停止为root?
我的解决方案是停止自动弹出到根视图控制器:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
UITabBarController *tbc = [[UITabBarController alloc]init];
tbc.viewControllers = [NSArray arrayWithObjects:rvc,nil];
tbc.delegate = self;}
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
if([tabBarController selectedViewController] == viewController)
return NO;
return YES;}
如果您有另一个解决方案,请记下好处。
答案 0 :(得分:0)
在标签栏应用中尝试此代码
[self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
答案 1 :(得分:0)
您在新的viewController中实现了didSelectViewController方法(推送到新的viewController)
导入UITabBarControllerDelegate,
- (void)viewDidLoad
{
[super viewDidLoad];
self.tabBarController.delegate = self;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
[self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
}