1.UIImageView Animationimages Properties
1 > memory is not automatically freed after adding pictures
2> Animationimages will automatically release the memory that was loaded before the image was assigned nil
-(void) Runanimationwithcount: (int) count name: (NSString *) name{if (self.tom.isAnimating) return; 1. Load all animated pictures Nsmutablearray *images = [Nsmutablearray array]; for (int i = 0; i<count; i++) {//Calculate file name NSString *filename = [NSString stringwithformat:@ "%@_%02d.jpg", name, I]; Load picture//imagenamed: There is a cache (incoming file name)//UIImage *image = [UIImage imagenamed:filename]; Imagewithcontentsoffile: No cache (full path of incoming file) nsbundle *bundle = [NSBundle mainbundle]; NSString *path = [bundle pathforresource:filename Oftype:nil]; UIImage *image = [UIImage Imagewithcontentsoffile:path]; Add a picture to the array [images addobject:image]; } self.tom.animationImages = images; 2. Set the number of plays (1 times) Self.tom.animationRepeatCount = 1; 3. Set playback Time Self.tom.animationDuration = Images.count * 0.05; [Self.tom startanimating]; 4. Erase memory after 1 seconds of animation cgfloat delay = Self.tom.animationDUration + 1.0; [Self.tom performselector: @selector (setanimationimages:) Withobject:nil afterdelay:delay];//[self performSelector: @selector (ClearCache) Withobject:nil afterdelay:delay];}
4.ios Picture Animation loading