0
在prepareForSegue期间,是否可以修改父视图控制器中的标签栏项目?基本上,我试图在父控制器中插入逻辑,其中2个可能的标签栏项中的一个可能在继续移除时被删除。在父视图控制器中修改标签栏项目
我试图沿着线的东西:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"identifierOfInterest"]) {
UITabBarController *tabBarController = (UITabBarController *)segue.destinationViewController;
// Attempt 1
NSMutableArray *items = [[tabBarController.tabBar items] mutableCopy];
[items removeObjectAtIndex:1];
[tabBarController.tabBar setItems:items animated:YES];
// Attempt 2
NSMutableArray *items = [[tabBarController viewControllers] mutableCopy];
[items removeObjectAtIndex:1];
[tabBarController setViewControllers:items];
}
}
不幸的是这两条消息崩溃与以下错误应用程序:
尝试1:
Directly modifying a tab bar managed by a tab bar controller is not allowed.
尝试2:
[UITabBarItem parentViewController]: unrecognized selector sent to instance
我正在使用Xcode 4.2,iOS 5与UI Tab Bar Controller是一个故事板对象,所以没有出口到标签栏或任何东西。
在此先感谢!