在我的项目中,我有 10 个视图控制器:Navigation-> 1-> 2-> 3-> 4-> 5-> 6-> 7-> 8-> 9-> 10;任何视图控制器都有自定义动画,使用导航控制器,我使用模态 segue 交叉溶解的一对一视图控制器,我也可以以这种方式返回 10-> 9-> 8-> 7-> 6-> 5 -> 4-> 3-> 2-> 1;,但是当我在 8 或 9 视图控制器中时,应用程序关闭或崩溃,我不知道为什么!!!,我使用的代码对于任何视图控制器是:
- (void)viewDidLoad
{
NSLog(@"view did load");
[super viewDidLoad];
// Do any additional setup after loading the view.
[self mostrarAnimacion];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
NSLog(@"Problemas de Memoria View Controller #(number of ViewController)");
}
- (void)getArrayEffectAnimacion
{
NSMutableArray *arrayBall = [[NSMutableArray alloc] init];
for (int i=0; i<9; i++) {
UIImage *image = [UIImage imageWithData:
[NSData dataWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:
[NSString stringWithFormat:@"imagen00%d.png", i] ofType:nil]]];
[arrayBall addObject:image];
}
self.arrayEffectAnimacion = [NSArray arrayWithArray:arrayBall];
}
-(IBAction)Animacion
{
[self getArrayEffectAnimacion];
self.imgAnimacion.animationImages = self.arrayEffectAnimacion;
self.imgAnimacion.animationDuration = 1.0f;
[self.imgAnimacion setAnimationRepeatCount:1];
[self.imgAnimacion startAnimating];
}
- (void)viewWillDisappear:(BOOL)animated
{
NSLog(@"View controller #(number of viewcontroller) desaparece");
[super viewWillDisappear:animated];
self.imgAnimacion.animationImages = nil;
}
- (void) mostrarAnimacion
{
if (ES_IPAD())
{
[UIView animateWithDuration:15.0f delay:1
options:UIViewAnimationOptionRepeat animations:^{
imagen.frame =
CGRectMake(1024,imagen.frame.origin.y,
imagen.frame.size.width,
imagen.frame.size.height);
} completion:nil];
}
else
{
if (ES_IPHONE_5)
{
[UIView animateWithDuration:25.0f delay:1
options:UIViewAnimationOptionRepeat animations:^{
imagen.frame = CGRectMake(568,imagen.frame.origin.y,
imagen.frame.size.width, imagen.frame.size.height);
} completion:nil];
}
else
{
[UIView animateWithDuration:25.0f delay:1
options:UIViewAnimationOptionRepeat animations:^{
ViewNubes.frame = CGRectMake(480,imagen.frame.origin.y,
imagen.frame.size.width, imagen.frame.size.height);
} completion:nil];
}
}
}
-(IBAction)TapUNO:(UITapGestureRecognizer *)recognizer
{
dispatch_async(dispatch_get_main_queue(), ^{
[self Animacion];
});
}
因此,当我在 8 或 9 视图控制器中时,应用程序崩溃或关闭并向我打印 nslog:仅在崩溃前的最后一个视图控制器中
2013-08-26 12:15:18.292 PRUEBA[214:907] Received memory warning.
2013-08-26 12:15:18.310 PRUEBA[214:907] Problemas de Memoria View Controller 01
2013-08-26 12:15:18.314 PRUEBA[214:907] Problemas de Memoria View Controller 02
2013-08-26 12:15:18.318 PRUEBA[214:907] Problemas de Memoria View Controller 01
2013-08-26 12:15:18.319 PRUEBA[214:907] Problemas de Memoria View Controller 02
2013-08-26 12:15:18.321 PRUEBA[214:907] Problemas de Memoria View Controller 03
2013-08-26 12:15:18.324 PRUEBA[214:907] Problemas de Memoria View Controller 04
2013-08-26 12:15:18.327 PRUEBA[214:907] Problemas de Memoria View Controller 05
2013-08-26 12:15:18.328 PRUEBA[214:907] Problemas de Memoria View Controller 06
2013-08-26 12:15:18.330 PRUEBA[214:907] Problemas de Memoria View Controller 07
2013-08-26 12:15:18.333 PRUEBA[214:907] Problemas de Memoria View Controller 08
2013-08-26 12:15:18.336 PRUEBA[214:907] Problemas de Memoria View Controller 09
就像每个视图控制器都会一直运行但只向我展示实际情况,那么我如何才能完成或关闭视图控制器以进行下一个或另一个,是为了模态segue?在交叉溶解中?,我以错误的方式使用动画?,我看到另一个问题,但是,我不知道如何解决这个问题!!!如何解决这个问题?,我在 iOS 6 上使用 xcode 4.5
好的,现在突然得到这个我或打印我:
2013-08-26 18:41:56.717 PRUEBA[7488:907] view did load page 1
2013-08-26 18:42:17.848 PRUEBA[7488:907] view did load page 2
2013-08-26 18:42:18.219 PRUEBA[7488:907] page 1 desaparece
2013-08-26 18:42:33.903 PRUEBA[7488:907] view did load page 3
2013-08-26 18:42:34.283 PRUEBA[7488:907] page 2 desaparece
2013-08-26 18:42:48.345 PRUEBA[7488:907] view did load page 4
2013-08-26 18:42:48.707 PRUEBA[7488:907] page 3 desaparece
2013-08-26 18:43:02.223 PRUEBA[7488:907] view did load page 5
2013-08-26 18:43:02.565 PRUEBA[7488:907] page 4 desaparece
2013-08-26 18:43:15.596 PRUEBA[7488:907] view did load page 6
2013-08-26 18:43:15.896 PRUEBA[7488:907] page 5 desaparece
2013-08-26 18:43:22.393 PRUEBA[7488:907] view did load page 7
2013-08-26 18:43:22.791 PRUEBA[7488:907] page 6 desaparece
2013-08-26 18:43:27.868 PRUEBA[7488:907] view did load page 8
2013-08-26 18:43:28.250 PRUEBA[7488:907] page 7 desaparece
2013-08-26 18:43:33.504 PRUEBA[7488:907] view did load page 9
2013-08-26 18:43:33.797 PRUEBA[7488:907] page 8 desaparece
2013-08-26 18:43:43.015 PRUEBA[7488:907] view did load page 10
2013-08-26 18:43:43.505 PRUEBA[7488:907] page 9 desaparece
2013-08-26 18:46:23.233 PRUEBA[7488:907] Received memory warning.
2013-08-26 18:46:23.635 PRUEBA[7488:907] Problemas de Memoria View Controller 01
2013-08-26 18:46:23.755 PRUEBA[7488:907] Problemas de Memoria View Controller 02
2013-08-26 18:46:23.786 PRUEBA[7488:907] Problemas de Memoria View Controller 03
2013-08-26 18:46:23.828 PRUEBA[7488:907] Problemas de Memoria View Controller 04
2013-08-26 18:46:23.841 PRUEBA[7488:907] Problemas de Memoria View Controller 05
2013-08-26 18:46:23.862 PRUEBA[7488:907] Problemas de Memoria View Controller 06
2013-08-26 18:46:23.875 PRUEBA[7488:907] Problemas de Memoria View Controller 07
2013-08-26 18:46:23.889 PRUEBA[7488:907] Problemas de Memoria View Controller 08
2013-08-26 18:46:23.908 PRUEBA[7488:907] Problemas de Memoria View Controller 09
2013-08-26 18:46:23.946 PRUEBA[7488:907] Problemas de Memoria View Controller 10
2013-08-26 18:46:23.990 PRUEBA[7488:907] Problemas de Memoria View Controller 09
2013-08-26 18:46:24.040 PRUEBA[7488:907] Problemas de Memoria View Controller 08
2013-08-26 18:46:24.054 PRUEBA[7488:907] Problemas de Memoria View Controller 07
2013-08-26 18:46:32.077 PRUEBA[7488:907] view did load page 1
2013-08-26 18:46:32.704 PRUEBA[7488:907] view did load page 2
2013-08-26 18:46:33.090 PRUEBA[7488:907] view did load page 3
2013-08-26 18:46:33.521 PRUEBA[7488:907] view did load page 4
2013-08-26 18:46:33.946 PRUEBA[7488:907] view did load page 5
2013-08-26 18:46:34.354 PRUEBA[7488:907] view did load page 6
2013-08-26 18:46:34.821 PRUEBA[7488:907] view did load page 7
2013-08-26 18:46:35.368 PRUEBA[7488:907] view did load page 8
2013-08-26 18:46:35.857 PRUEBA[7488:907] view did load page 9
为什么所有视图控制器的 viewDidLoad 方法同时从每个视图控制器运行???是记忆的问题吗?导航??请帮助伙计们