Я разрабатывал на платформе iPhone очень короткое время, и у меня уже была своя доля ошибок синтаксиса, а теперь проблемы с памятью.
В моем приложении для iPhone представление изображений несколько раз анимируется различными кнопками (6), и это без проблем работает на iPhone, но когда я впервые протестировал свое приложение с инструментами, он обнаружил 1 или 2 памяти Утечки, утечки памяти происходят, когда вызывается IBAction, который выполняет анимацию и это звуковой эффект. Теперь я понимаю, что такое утечка памяти, но мало знаю о том, как их предотвратить,
Стоит ли мне даже беспокоиться из-за утечки памяти в несколько килобайт, учитывая, что я планирую добавить больше анимаций позже?
Помощь будет высоко оценена.
Вот мой код:
#import "00001111ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
@implementation 00001111ViewController
@synthesize leftSwitch;
@synthesize rightSwitch;
@synthesize switchView;
@synthesize myScrollView1;
@synthesize img;
- (void)viewDidLoad {
blinkTimer = [NSTimer scheduledTimerWithTimeInterval:(1.00/1.00) target:self selector:@selector(blink) userInfo:nil repeats:NO];
[blinkTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%10]];
}
- (void)blink{
[self animateBlink];
}
- (void)animateBlink{
UIImage *openeye = [UIImage imageNamed:@"img.png"];
UIImage *closedeye = [UIImage imageNamed:@"cloudnewimprovedblinked.png"];
if(img.image == openeye)
img.image = closedeye;
else if(img.image == closedeye)
img.image = openeye;
else
img.image == closedeye;
blinkTimer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(blink) userInfo:nil repeats:NO];
if (img.image == openeye)
[blinkTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%10]];
}
-(IBAction)toggleShowHide2:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
}
-(IBAction)toggleShowHide1:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 1];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[switchView setAlpha:.88];
[UIView commitAnimations];
}
- (IBAction)startClick:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound1=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"clickwithsilence" ofType:@"wav"]] error:NULL];
animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"imgapple0001.png"],
[UIImage imageNamed: @"imgapple0002.png"],
[UIImage imageNamed: @"imgapple0003.png"],
[UIImage imageNamed: @"imgapple0004.png"],
[UIImage imageNamed: @"imgapple0005.png"],
[UIImage imageNamed: @"imgapple0006.png"],
[UIImage imageNamed: @"imgapple0007.png"],
[UIImage imageNamed: @"imgapple0008.png"],
[UIImage imageNamed: @"imgapple0009.png"],
[UIImage imageNamed: @"imgapple0010.png"],
[UIImage imageNamed: @"imgapple0011.png"],
[UIImage imageNamed: @"imgapple0013.png"],
[UIImage imageNamed: @"imgapple0014.png"],
[UIImage imageNamed: @"imgapple0015.png"],
[UIImage imageNamed: @"imgapple0016.png"],
[UIImage imageNamed: @"imgapple0017.png"],
[UIImage imageNamed: @"imgapple0018.png"],
[UIImage imageNamed: @"imgapple0019.png"],
[UIImage imageNamed: @"imgapple0020.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =.7;
[img startAnimating];
[sound1 play];
}
- (void)tick{
[self animateYes];
}
- (void)animateYes{
UIImage *YesImage13=[UIImage imageNamed:@"imgapple0020.png"];
if(img.image == YesImage13)
img.image = YesImage13;
else
img.image = YesImage13;
if(img.image == YesImage13)
blinkTimer2 = [NSTimer scheduledTimerWithTimeInterval:(1.00/1.00) target:self selector:@selector(blink2) userInfo:nil repeats:NO];
[blinkTimer2 setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%7]];
}
- (void)blink2{
[self animateBlink2];
}
- (void)animateBlink2{
UIImage *openeye2 = [UIImage imageNamed:@"imgapple0020.png"];
UIImage *closedeye2 = [UIImage imageNamed:@"appleblinked.png"];
if(img.image == openeye2)
img.image = closedeye2;
else if(img.image == closedeye2)
img.image = openeye2;
else
img.image == closedeye2;
blinkTimer2 = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(blink2) userInfo:nil repeats:NO];
if (img.image == openeye2)
[blinkTimer2 setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%10]];
}
- (IBAction)startClick1:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound2=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"explosiontrimmed" ofType:@"wav"]] error:NULL];
animationTimer1 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick1) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"img0015.png"],
[UIImage imageNamed: @"img0016.png"],
[UIImage imageNamed: @"img0017.png"],
[UIImage imageNamed: @"img0018.png"],
[UIImage imageNamed: @"img0019.png"],
[UIImage imageNamed: @"img0020.png"],
[UIImage imageNamed: @"img0021.png"],
[UIImage imageNamed: @"img0022.png"],
[UIImage imageNamed: @"img0023.png"],
[UIImage imageNamed: @"img0024.png"],
[UIImage imageNamed: @"img0025.png"],
[UIImage imageNamed: @"img0026.png"],
[UIImage imageNamed: @"img0027.png"],
[UIImage imageNamed: @"img0028.png"],
[UIImage imageNamed: @"img0029.png"],
[UIImage imageNamed: @"img0030.png"],
[UIImage imageNamed: @"img0031.png"],
[UIImage imageNamed: @"img0032.png"],
[UIImage imageNamed: @"img0033.png"],
[UIImage imageNamed: @"img0034.png"],
[UIImage imageNamed: @"img0035.png"],
[UIImage imageNamed: @"img0036.png"],
[UIImage imageNamed: @"img0037.png"],
[UIImage imageNamed: @"img0038.png"],
[UIImage imageNamed: @"img0039.png"],
[UIImage imageNamed: @"img0040.png"],
[UIImage imageNamed: @"img0041.png"],
[UIImage imageNamed: @"img0042.png"],
[UIImage imageNamed: @"img0043.png"],
[UIImage imageNamed: @"img0044.png"],
[UIImage imageNamed: @"img0045.png"],
[UIImage imageNamed: @"img0046.png"],
[UIImage imageNamed: @"img0047.png"],
[UIImage imageNamed: @"img0048.png"],
//and so on to 100
nil];
[img setAnimationRepeatCount:1];
img.animationDuration =2.7;
[img startAnimating];
[sound2 play];
}
- (void)tick1{
[self animateYes1];
}
- (void) animateYes1{
UIImage *YesImage11=[UIImage imageNamed:@"img0048.png"];
if(img.image == YesImage11)
img.image = YesImage11;
else
img.image = YesImage11;
if(img.image == YesImage11)
blinkTimer1 = [NSTimer scheduledTimerWithTimeInterval:(1.00/1.00) target:self selector:@selector(blink1) userInfo:nil repeats:NO];
[blinkTimer1 setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%7]];
}
- (void)blink1{
[self animateBlink1];
}
- (void)animateBlink1{
UIImage *openeye1 = [UIImage imageNamed:@"img0048.png"];
UIImage *closedeye1 = [UIImage imageNamed:@"explosionblinked.png"];
if(img.image == openeye1)
img.image = closedeye1;
else if(img.image == closedeye1)
img.image = openeye1;
else
img.image == closedeye1;
blinkTimer1 = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(blink1) userInfo:nil repeats:NO];
if (img.image == openeye1)
[blinkTimer1 setFireDate:[NSDate dateWithTimeIntervalSinceNow:rand()%7]];
}
- (IBAction)startClick2:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound3=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"watersplashsilence" ofType:@"wav"]] error:NULL];
animationTimer2 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick2) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"imgshark0001.png"],
[UIImage imageNamed: @"imgshark0002.png"],
[UIImage imageNamed: @"imgshark0003.png"],
[UIImage imageNamed: @"imgshark0004.png"],
[UIImage imageNamed: @"imgshark0005.png"],
[UIImage imageNamed: @"imgshark0006.png"],
[UIImage imageNamed: @"imgshark0007.png"],
[UIImage imageNamed: @"imgshark0008.png"],
[UIImage imageNamed: @"imgshark0009.png"],
[UIImage imageNamed: @"imgshark0010.png"],
[UIImage imageNamed: @"imgshark0011.png"],
[UIImage imageNamed: @"imgshark0012.png"],
[UIImage imageNamed: @"imgshark0013.png"],
[UIImage imageNamed: @"imgshark0014.png"],
[UIImage imageNamed: @"imgshark0015.png"],
[UIImage imageNamed: @"imgshark0016.png"],
[UIImage imageNamed: @"imgshark0017.png"],
[UIImage imageNamed: @"imgshark0018.png"],
[UIImage imageNamed: @"imgshark0019.png"],
[UIImage imageNamed: @"imgshark0020.png"],
[UIImage imageNamed: @"imgshark0021.png"],
[UIImage imageNamed: @"imgshark0022.png"],
[UIImage imageNamed: @"imgshark0023.png"],
[UIImage imageNamed: @"imgshark0024.png"],
[UIImage imageNamed: @"imgshark0025.png"],
[UIImage imageNamed: @"imgshark0026.png"],
[UIImage imageNamed: @"imgshark0027.png"],
[UIImage imageNamed: @"imgshark0028.png"],
[UIImage imageNamed: @"imgshark0029.png"],
[UIImage imageNamed: @"imgshark0030.png"],
[UIImage imageNamed: @"imgshark0031.png"],
[UIImage imageNamed: @"imgshark0032.png"],
[UIImage imageNamed: @"imgshark0033.png"],
[UIImage imageNamed: @"imgshark0034.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =2.8;
[img startAnimating];
[sound3 play];
}
- (void)tick2{
[self animateYes2];
}
- (void)animateYes2{
UIImage *YesImage14=[UIImage imageNamed:@"imgshark0034.png"];
if(img.image == YesImage14)
img.image = YesImage14;
else
img.image = YesImage14;
}
- (IBAction)startClick3:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound4=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"dogsilence" ofType:@"wav"]] error:NULL];
animationTimer3 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick3) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"imgdog0001.png"],
[UIImage imageNamed: @"imgdog0002.png"],
[UIImage imageNamed: @"imgdog0003.png"],
[UIImage imageNamed: @"imgdog0004.png"],
[UIImage imageNamed: @"imgdog0005.png"],
[UIImage imageNamed: @"imgdog0006.png"],
[UIImage imageNamed: @"imgdog0007.png"],
[UIImage imageNamed: @"imgdog0008.png"],
[UIImage imageNamed: @"imgdog0009.png"],
[UIImage imageNamed: @"imgdog0010.png"],
[UIImage imageNamed: @"imgdog0011.png"],
[UIImage imageNamed: @"imgdog0012.png"],
[UIImage imageNamed: @"imgdog0013.png"],
[UIImage imageNamed: @"imgdog0014.png"],
[UIImage imageNamed: @"imgdog0015.png"],
[UIImage imageNamed: @"imgdog0016.png"],
[UIImage imageNamed: @"imgdog0017.png"],
[UIImage imageNamed: @"imgdog0018.png"],
[UIImage imageNamed: @"imgdog0019.png"],
[UIImage imageNamed: @"imgdog0020.png"],
[UIImage imageNamed: @"imgdog0021.png"],
[UIImage imageNamed: @"imgdog0022.png"],
[UIImage imageNamed: @"imgdog0023.png"],
[UIImage imageNamed: @"imgdog0024.png"],
[UIImage imageNamed: @"imgdog0025.png"],
[UIImage imageNamed: @"imgdog0026.png"],
[UIImage imageNamed: @"imgdog0026.png"],
[UIImage imageNamed: @"imgdog0028.png"],
[UIImage imageNamed: @"imgdog0029.png"],
[UIImage imageNamed: @"imgdog0030.png"],
[UIImage imageNamed: @"imgdog0031.png"],
[UIImage imageNamed: @"imgdog0032.png"],
[UIImage imageNamed: @"imgdog0033.png"],
[UIImage imageNamed: @"imgdog0034.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =2.7;
[img startAnimating];
[sound4 play];
}
- (void)tick3{
[self animateYes3];
}
- (void)animateYes3{
UIImage *YesImage14=[UIImage imageNamed:@"imgdog0034.png"];
if(img.image == YesImage14)
img.image = YesImage14;
else
img.image = YesImage14;
}
- (IBAction)startClick4:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound5=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"arrowhitting" ofType:@"wav"]] error:NULL];
animationTimer4 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick4) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"imgarrow0001.png"],
[UIImage imageNamed: @"imgarrow0002.png"],
[UIImage imageNamed: @"imgarrow0003.png"],
[UIImage imageNamed: @"imgarrow0004.png"],
[UIImage imageNamed: @"imgarrow0005.png"],
[UIImage imageNamed: @"imgarrow0006.png"],
[UIImage imageNamed: @"imgarrow0007.png"],
[UIImage imageNamed: @"imgarrow0008.png"],
[UIImage imageNamed: @"imgarrow0009.png"],
[UIImage imageNamed: @"imgarrow0010.png"],
[UIImage imageNamed: @"imgarrow0011.png"],
[UIImage imageNamed: @"imgarrow0012.png"],
[UIImage imageNamed: @"imgarrow0013.png"],
[UIImage imageNamed: @"imgarrow0014.png"],
[UIImage imageNamed: @"imgarrow0015.png"],
[UIImage imageNamed: @"imgarrow0016.png"],
[UIImage imageNamed: @"imgarrow0017.png"],
[UIImage imageNamed: @"imgarrow0018.png"],
[UIImage imageNamed: @"imgarrow0019.png"],
[UIImage imageNamed: @"imgarrow0020.png"],
[UIImage imageNamed: @"imgarrow0021.png"],
[UIImage imageNamed: @"imgarrow0022.png"],
[UIImage imageNamed: @"imgarrow0023.png"],
[UIImage imageNamed: @"imgarrow0024.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =.7;
[img startAnimating];
[sound5 play];
}
- (void)tick4{
[self animateYes4];
}
- (void)animateYes4{
UIImage *YesImage15=[UIImage imageNamed:@"imgarrow0024.png"];
if(img.image == YesImage15)
img.image = YesImage15;
else
img.image = YesImage15;
}
- (IBAction)startClick5:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound6=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"imgquote1" ofType:@"wav"]] error:NULL];
animationTimer5 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick5) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"qotebandb0000.png"],
[UIImage imageNamed: @"qotebandb0001.png"],
[UIImage imageNamed: @"qotebandb0002.png"],
[UIImage imageNamed: @"qotebandb0003.png"],
[UIImage imageNamed: @"qotebandb0004.png"],
[UIImage imageNamed: @"qotebandb0005.png"],
[UIImage imageNamed: @"qotebandb0006.png"],
[UIImage imageNamed: @"qotebandb0007.png"],
[UIImage imageNamed: @"qotebandb0008.png"],
[UIImage imageNamed: @"qotebandb0009.png"],
[UIImage imageNamed: @"qotebandb0010.png"],
[UIImage imageNamed: @"qotebandb0011.png"],
[UIImage imageNamed: @"qotebandb0012.png"],
[UIImage imageNamed: @"qotebandb0013.png"],
[UIImage imageNamed: @"qotebandb0014.png"],
[UIImage imageNamed: @"qotebandb0015.png"],
[UIImage imageNamed: @"qotebandb0016.png"],
[UIImage imageNamed: @"qotebandb0017.png"],
[UIImage imageNamed: @"qotebandb0018.png"],
[UIImage imageNamed: @"qotebandb0019.png"],
[UIImage imageNamed: @"qotebandb0020.png"],
[UIImage imageNamed: @"qotebandb0021.png"],
[UIImage imageNamed: @"qotebandb0022.png"],
[UIImage imageNamed: @"qotebandb0023.png"],
[UIImage imageNamed: @"qotebandb0024.png"],
[UIImage imageNamed: @"qotebandb0025.png"],
[UIImage imageNamed: @"qotebandb0026.png"],
[UIImage imageNamed: @"qotebandb0027.png"],
[UIImage imageNamed: @"qotebandb0028.png"],
[UIImage imageNamed: @"qotebandb0029.png"],
[UIImage imageNamed: @"qotebandb0030.png"],
[UIImage imageNamed: @"qotebandb0031.png"],
[UIImage imageNamed: @"qotebandb0032.png"],
[UIImage imageNamed: @"qotebandb0033.png"],
[UIImage imageNamed: @"qotebandb0034.png"],
[UIImage imageNamed: @"qotebandb0035.png"],
[UIImage imageNamed: @"qotebandb0036.png"],
[UIImage imageNamed: @"qotebandb0037.png"],
[UIImage imageNamed: @"qotebandb0038.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =3.1;
[img startAnimating];
[sound6 play];
}
- (void)tick5{
[self animateYes5];
}
- (void)animateYes5{
UIImage *YesImage17=[UIImage imageNamed:@"qotebandb0038.png"];
if(img.image == YesImage17)
img.image = YesImage17;
else
img.image = YesImage17;
}
- (IBAction)startClick6:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[switchView setAlpha:0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[myScrollView1 setAlpha: 0];
[UIView commitAnimations];
sound7=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"audiop" ofType:@"wav"]] error:NULL];
animationTimer6 = [NSTimer scheduledTimerWithTimeInterval:(1.00/30.00) target:self selector:@selector(tick6) userInfo:nil repeats:NO];
img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @"hammer0001.png"],
[UIImage imageNamed: @"hammer0002.png"],
[UIImage imageNamed: @"hammer0003.png"],
[UIImage imageNamed: @"hammer0004.png"],
[UIImage imageNamed: @"hammer0005.png"],
[UIImage imageNamed: @"hammer0006.png"],
[UIImage imageNamed: @"hammer0007.png"],
[UIImage imageNamed: @"hammer0008.png"],
[UIImage imageNamed: @"hammer0009.png"],
[UIImage imageNamed: @"hammer0010.png"],
[UIImage imageNamed: @"hammer0011.png"],
[UIImage imageNamed: @"hammer0012.png"],
[UIImage imageNamed: @"hammer0013.png"],
[UIImage imageNamed: @"hammer0014.png"],
[UIImage imageNamed: @"hammer0015.png"],
[UIImage imageNamed: @"hammer0016.png"],
[UIImage imageNamed: @"hammer0017.png"],
[UIImage imageNamed: @"hammer0018.png"],
[UIImage imageNamed: @"hammer0019.png"],
[UIImage imageNamed: @"hammer0020.png"],
[UIImage imageNamed: @"hammer0021.png"],
[UIImage imageNamed: @"hammer0022.png"],
[UIImage imageNamed: @"hammer0023.png"],
[UIImage imageNamed: @"hammer0024.png"],
[UIImage imageNamed: @"hammer0025.png"],
[UIImage imageNamed: @"hammer0026.png"],
[UIImage imageNamed: @"hammer0027.png"],
[UIImage imageNamed: @"hammer0028.png"],
[UIImage imageNamed: @"hammer0029.png"],
[UIImage imageNamed: @"hammer0030.png"],
[UIImage imageNamed: @"hammer0031.png"],
[UIImage imageNamed: @"hammer0032.png"],
[UIImage imageNamed: @"hammer0033.png"],
[UIImage imageNamed: @"hammer0034.png"],nil];
[img setAnimationRepeatCount:1];
img.animationDuration =2.25;
[img startAnimating];
[sound7 play];
}
- (void)tick6{
[self animateYes6];
}
- (void)animateYes6{
UIImage *YesImage18=[UIImage imageNamed:@"img.png"];
if(img.image == YesImage18)
img.image = YesImage18;
else
img.image = YesImage18;
}
- (void)stopTimer
{
[animationTimer invalidate];
[animationTimer release];
[animationTimer1 invalidate];
[animationTimer1 release];
[animationTimer2 invalidate];
[animationTimer2 release];
[animationTimer3 invalidate];
[animationTimer3 release];
[blinkTimer invalidate];
[blinkTimer release];
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
img.center = location;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
// Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
- (void)dealloc {
[super dealloc];
[img release];
[sound1 release];
[sound2 release];
[sound3 release];
[sound4 release];
[sound5 release];
[sound6 release];
[sound7 release];
}
@end
Просто чтобы уточнить, таймеры используются для установки каждого отдельного анимационного изображения в последнем кадре в качестве изображения imageView.