Я пытаюсь смоделировать анимацию на основе серии из 54 изображений.Я получаю - «Программа получила сигнал:« 0 ».»сообщение - не хватает памяти.
Я стараюсь изо всех сил, чтобы заботиться о них, я, кажется, не удается.Я пробегаю все 54 примерно за 4-5 секунд, а затем это должно повториться (почти как перевернутая книга).Анимация - это не то, что легко сделать с помощью анимации Core из-за блестящего 3D материала на изображении.
Или есть ли лучший способ сделать это?:
-(void)addImage:(NSString*)imageName{
if (self.images == nil){
self.images = [[[NSMutableArray alloc] init] autorelease];
}
[self.images addObject:[UIImage imageNamed:imageName]];
}
// Returns a UIImageView that contains the next image to display
- (UIImageView *)nextImageView
{
// get the image at the next index
UIImage *image = [images objectAtIndex:pictureIndex];
++pictureIndex; // increment the index
if(pictureIndex > images.count -1){
pictureIndex = 0;
}
// create an image view for the image
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// resize the image to fill the screen without distorting
imageView.frame = rotator.frame;
imageView.autoresizesSubviews = NO;
[imageView setContentMode:UIViewContentModeCenter];
// Makes the image move proportionally in any direction if the
// bounds of the superview change when the iPhone is 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 the animation length
[UIView setAnimationDelegate:self]; // set the animation delegate
// call the given method when the animation ends
[UIView setAnimationDidStopSelector:@selector(transitionFinished:finished:context:)];
// make the next image appear with the chosen effect
[nextImageView setAlpha:1.0]; // fade in the next image
[currentImageView setAlpha:0.0]; // fade out the old image
[UIView commitAnimations];
} else {
[timer invalidate];
timer = nil;
}
}
// called when the image transition animation finishes
- (void)transitionFinished:(NSString *)animationId finished:(BOOL)finished context:(void *)context
{
[currentImageView removeFromSuperview]; // remove the old image
[currentImageView release]; // release the memory for the old image
currentImageView = context; // assign the new image
}
-(void)startRotator{
self.rotator.animationImages = self.images;
self.rotator.animationDuration = animationDuration;
pictureIndex = 0; // reset the index
currentImageView = [self nextImageView]; // load the first image
[self.view addSubview:currentImageView]; // add the image to the 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];
}