【发布时间】:2012-03-13 07:36:16
【问题描述】:
AgentDashboardNavigationController 生存!
我继续执行相同的过程,我的 tabBarController 中的 agentDashboardNavigationController VC 被一个编辑界面 VC 替换。
完成后,编辑界面将替换为新的 agentDashboardNavigationController。
由于某种原因,活跃的 agentDashboardNavigationController 对象的数量不断增加。
基本上,我通过替换视图控制器的可变副本中的对象来来回翻转该选项卡中的内容。
agentDashboardNavigationController 被换入:
NSMutableArray *newViewControllers = [self.mainTabBarController.viewControllers mutableCopy];
AgentDashboardNavigationController *agentDashboardNavigationController = [[AgentDashboardNavigationController alloc] init];
// cycle through until we find the agentcontroller and remove it
// for now that's the only controller that gets removed so we break
NSUInteger index = [newViewControllers indexOfObjectPassingTest: ^ BOOL (id obj, NSUInteger idx, BOOL *stop) {
return [[obj tabBarItem].title isEqualToString:@"Guest Card"];
}];
[newViewControllers replaceObjectAtIndex:index withObject:agentDashboardNavigationController];
[self.mainTabBarController setViewControllers:newViewControllers animated:NO];
[newViewControllers release];
[agentDashboardNavigationController release];
它被换掉了:
UISplitViewController *splitVC = self.guestCardManagementController.splitViewController;
// remove agentTab
NSMutableArray *newViewControllers = [self.mainTabBarController.viewControllers mutableCopy];
// cycle through until we find the agentcontroller and remove it
NSUInteger index = [newViewControllers indexOfObjectPassingTest: ^ BOOL (id obj, NSUInteger idx, BOOL *stop) {
return [obj class] == [AgentDashboardNavigationController class];
}];
[newViewControllers replaceObjectAtIndex:index withObject:splitVC];
[self.mainTabBarController setViewControllers:newViewControllers animated:NO];
[newViewControllers release];
【问题讨论】:
标签: objective-c ios memory memory-management