我在viewDidLoad
函数中创建了一个包含此代码的视图控制器:
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View1"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View2"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View3"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View4"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View5"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View6"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View7"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View8"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View9"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View10"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View11"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View12"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View13"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View14"]];
当我打开一个新的ViewController并使用以下代码返回初始ViewController时:
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Home"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:NULL];
我收到了记忆警告。
答案 0 :(得分:2)
您没有返回到那里的主视图控制器,您正在创建一个新的家庭控制器实例并进行呈现。做足够多次,最终得到一大堆控制器和低内存情况。
请尝试解雇您的控制器,尽管从您的问题中不清楚如何使用其中的所有子控制器访问VC。