0

in my project I have like 10 view controllers: Navigation-> 1-> 2-> 3-> 4-> 5-> 6-> 7-> 8-> 9-> 10; any view controller have a custom animation, with the navigation controller I go one for one view controller with a modal segue cross dissolve, I can Go back in this way too 10-> 9-> 8-> 7-> 6-> 5-> 4-> 3-> 2-> 1;, but when I'm in the 8 or 9 view controller the app close, or crashes, and I don't know WHY!!!, the code I'm use for any view controller is:

- (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];
    });
}

So when I'm in the 8 or 9 view controller the app Crashes or close and print me the nslog's: only in the last view controller before crashes

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

is like if each view controller will run all the time but only show me the actual, so how can I finish or close a view controller to go the next or another, is for the modal segue?? in cross dissolve?, Im using in wrong way the animations?, I see another questions but, I don't know how fix this!!! how fix this any help?, Im using xcode 4.5 for iOS 6

OK suddenly get this me now or print me:

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

why from all viewcontroller the viewDidLoad method run in the same time from each viewcontroller??? is problem from memory? Navigation?? please help guys

user_Dennis_Mostajo
  • 2,279
  • 4
  • 28
  • 38
  • Why do u use UIImage *image = [UIImage imageWithData.. ] instead [UIImage imageNamed:@"imageName0.png"]; The method [UIImage imageNamed:@""] caches the image. it could be large images.. – Evgeniy S Aug 26 '13 at 20:18
  • Thanks for comment!!, and yes!! the images are larges, really BIG!!! so, doing the test, I found it better to do it this way, according to these questions [link1](http://stackoverflow.com/questions/5882820/which-take-less-memory-uiimage-and-image-with-content-of-file-in-iphone) and [link2](http://stackoverflow.com/questions/316236/difference-between-uiimage-imagenamed-and-uiimage-imagewithdata), but for clear memory I prefer not use in the cache memory, so any idea how can I fix this? – user_Dennis_Mostajo Aug 26 '13 at 20:44
  • try to use [self.imgAnimacion STOPAnimating] before self.imgBebeChupete.animationImages = nil; on viewWillDisappear method. And you use REPEAT - maybe it will be better to use cached images for REPEAT mode. Also i shell to recommend try to use Profile (Memory and/or Time profile) in Instruments – Evgeniy S Aug 26 '13 at 20:47
  • ALso adopt images size to every device. For iPhone you don't need images like for iPad. for 3Gs you don't need images like for 4(4s), etc.. Try to compress images as much as you can. – Evgeniy S Aug 26 '13 at 20:52
  • thanks, but I tried it and saw in profile to analyze leaks, although the memory is high, it works when I use iOS simulator, but when I run on the actual device, I still have the same problem, the app crash so I think I should not use the cache, I need a way to clean each view controller, or stop each view controller before the start the next, I will try with ViewDidUnLoad, but is deprecated for iOS 6 too ANY HELP T_T??? – user_Dennis_Mostajo Aug 26 '13 at 21:08
  • and each Image, have the size for the retina device, so if is iPad the png file is [1536x2048] for iPhone 4S is [640x960] and iPhone 5 is [640x1136] all in pixels, each animation is like a Background animation for any viewcontroller, I see another questions, is the memory? is the navigation controller? please help guys!! T_T – user_Dennis_Mostajo Aug 26 '13 at 21:17

0 Answers0