Iphone 选项卡栏方法?
我在视图控制器1中添加了这个选项卡栏,它工作得非常好,唯一的问题是我希望它执行以下功能Iphone 选项卡栏方法?,iphone,ios,objective-c,xcode,Iphone,Ios,Objective C,Xcode,我在视图控制器1中添加了这个选项卡栏,它工作得非常好,唯一的问题是我希望它执行以下功能[self.navigationController popViewControllerAnimated:YES],但当触碰选项卡栏按钮时,在视图控制器2中。最好的做法是什么 UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeViewC
[self.navigationController popViewControllerAnimated:YES]代码>,但当触碰选项卡栏按钮时,在视图控制器2中。最好的做法是什么
UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
homeNavigationController.tabBarItem = [[DSTabBarItem alloc] initWithFinishedSelectedImage:[UIImage imageNamed:@"home"]
finishedUnselectedImage:[UIImage imageNamed:@"home1"]
iconSize:CGSizeMake(76, 59)
tag:0];
[tabBarViewControllers addObject:homeNavigationController];
如果以编程方式添加tabbarcontroller。在该类中添加以下方法。
然后,导航控制器将更改为根视图。您可以根据自己的要求在if之间放置自己的
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([self.tabBarController.selectedViewController isKindOfClass:[UINavigationController class]])
{
[(UINavigationController*)self.tabBarController.selectedViewController popToRootViewControllerAnimated:YES];
}
}
你到底需要什么?
DetailSettingsViewController *settings = [[DetailSettingsViewController alloc] initWithNibName:@"DetailSettingsViewController" bundle:nil];
[self.navigationController pushViewController:settings animated:YES];