iphone - Mock Animation running out of memory -
i trying simulated animation based on series of 54 images. getting - "program received signal: “0”." message - running out of memory.
i trying best take care of them seem failing. running through 54 in 4-5 seconds, , should repeat (almost flip book). animation not can done using core animation due shiny 3d material in image.
or, there better way of going this?
here code:
-(void)addimage:(nsstring*)imagename{ if (self.images == nil){ self.images = [[[nsmutablearray alloc] init] autorelease]; } [self.images addobject:[uiimage imagenamed:imagename]]; } // returns uiimageview contains next image display - (uiimageview *)nextimageview { // image @ next index uiimage *image = [images objectatindex:pictureindex]; ++pictureindex; // increment index if(pictureindex > images.count -1){ pictureindex = 0; } // create image view image uiimageview *imageview = [[uiimageview alloc] initwithimage:image]; // resize image fill screen without distorting imageview.frame = rotator.frame; imageview.autoresizessubviews = no; [imageview setcontentmode:uiviewcontentmodecenter]; // makes image move proportionally in direction if // bounds of superview change when iphone rotated. imageview.autoresizingmask = (uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin | uiviewautoresizingflexibletopmargin | uiviewautoresizingflexiblebottommargin); return imageview; } - (void)timerfired:(nstimer *)_timer{ uiimageview *nextimageview = [self nextimageview]; if(nextimageview){ [self.view addsubview:nextimageview]; nextimageview.alpha = 0.0; //nslog(@"timerfired - image no: %i", pictureindex); // begin animation block [uiview beginanimations:nil context:nextimageview]; [uiview setanimationduration:animationduration]; // set animation length [uiview setanimationdelegate:self]; // set animation delegate // call given method when animation ends [uiview setanimationdidstopselector:@selector(transitionfinished:finished:context:)]; // make next image appear chosen effect [nextimageview setalpha:1.0]; // fade in next image [currentimageview setalpha:0.0]; // fade out old image [uiview commitanimations]; } else { [timer invalidate]; timer = nil; } } // called when image transition animation finishes - (void)transitionfinished:(nsstring *)animationid finished:(bool)finished context:(void *)context { [currentimageview removefromsuperview]; // remove old image [currentimageview release]; // release memory old image currentimageview = context; // assign new image } -(void)startrotator{ self.rotator.animationimages = self.images; self.rotator.animationduration = animationduration; pictureindex = 0; // reset index currentimageview = [self nextimageview]; // load first image [self.view addsubview:currentimageview]; // add image view //[self.rotator startanimating]; nslog(@"start animating - image count: %i", self.images.count); timer = [nstimer scheduledtimerwithtimeinterval:scheduledinterval target:self selector:@selector(timerfired:) userinfo:nil repeats:yes]; }
you leaking imageview
in nextimageview
. returned instance should autoreleased.
are sure 54 images fit memeory?
Comments
Post a Comment