在子控制器中,怎么直接返回首页(tabbar第0个元素)

来源:互联网 发布:网络101错误什么意思 编辑:程序博客网 时间:2024/05/16 18:34

顺序执行是不可以的

[self.navigationController popToRootViewControllerAnimated:NO];
self.tabBarController.selectedIndex = 0;

这个中方式会出问题,反正我在写的时候一直出问题,后来开启一个新的线程好了。

self.tabBarController.selectedIndex = 0;dispatch_queue_t queue =  dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(queue, ^{     [self.navigationController popToRootViewControllerAnimated:NO];});

这样就可以了。

0 0