目前,我试图通过以下代码以编程方式触发’didSelectViewController’方法:
self.tabController.selectedViewController = [self.tabController.viewControllers objectAtIndex:NEWSTAB_INDEX];
解决方法
self.tabController.selectedIndex = NEWSTAB_INDEX; // to actually switch to the controller (your code would work as well) - not sure if this does or not send the didSelectViewController: message to the delegate [self.tabController.delegate tabBarController:self.tabController didSelectViewController:[self.tabController.viewControllers objectAtIndex:NEWSTAB_INDEX]]; // send didSelectViewController to the tabBarController delegate