I have tabBarController in my app. when tap another tabBar that is UITableViewController the view is empty and cellForRowAtIndexPath dosen't fire(numberOfRowsInSection not zero or nil).
Code is:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
[[viewController navigationController] popToRootViewControllerAnimated:NO];
switch (tabBarController.tabBar.selectedItem.tag) {
case 1:
NSLog(@"Home");
break;
case 2:
NSLog(@"Profile");
break;
case 3:
{
NSLog(@"Bookmark");
BookmarkCategoryViewController *bookmarkVC =[self.storyboard instantiateViewControllerWithIdentifier:@"BookmarkCategory"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
/// Background work
BookmarkManager *p = [[BookmarkManager alloc]init];
[p fetchBookmarks:self.categoryId];
bookmarkVC.entries = p.appRecordList;
bookmarkVC.categoryId = self.categoryId;
bookmarkVC.ID_list_entries = _ID_list_entries;
[bookmarkVC.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
/// Update UI
[tabBarController setSelectedIndex:1];
});
});
}
break;
case 4:
NSLog(@"Setting");
break;
default:
NSLog(@"Home");
break;
}
}
but same code when change to:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
[[viewController navigationController] popToRootViewControllerAnimated:NO];
switch (tabBarController.tabBar.selectedItem.tag) {
case 1:
NSLog(@"Home");
break;
case 2:
NSLog(@"Profile");
break;
case 3:
{
NSLog(@"Bookmark");
BookmarkCategoryViewController *bookmarkVC =[self.storyboard instantiateViewControllerWithIdentifier:@"BookmarkCategory"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
// Background work
BookmarkManager *p = [[BookmarkManager alloc]init];
[p fetchBookmarks:self.categoryId];
bookmarkVC.entries = p.appRecordList;
bookmarkVC.categoryId = self.categoryId;
bookmarkVC.ID_list_entries = _ID_list_entries;
[bookmarkVC.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
/// Update UI
[bookmarkVC setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navigationController pushViewController:bookmarkVC animated:YES];
});
});
}
break;
case 4:
NSLog(@"Setting");
break;
default:
NSLog(@"Home");
break;
}
}
work correctly! but tabBarController hide and another view push to tabBarController view. Thanks for help.