我的应用程序中有许多动画(如 70 个、7 个视图控制器中的 10 个)具有相同类型的空隙和功能,当我在我的设备或模拟器中运行时,应用程序崩溃。
如何使用线程或调度改进这些动画,或者问题是内存?
如何做到这一点,在另一个问题和教程中,对动画使用相同的方法并且非常简单,代码是这样的,我对我的应用程序中需要的任何动画重复:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self CargarSonidos];
[self getArrayEffectImagen1];
self.imgImagen1.animationImages = self.arrayEffectImagen1;
self.imgImagen1.animationDuration = 1.0f;
[sonido play];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)getArrayEffectImagen1
{
NSMutableArray *arrayEfecto = [[NSMutableArray alloc] init];
for (int i=0; i<14; i++) {
UIImage *imagen = [UIImage imageNamed:[NSString stringWithFormat:@"Imagen%d.png",i]];
[arrayEfecto addObject:imagen];
}
self.arrayEffectImagen1 = [NSArray arrayWithArray:arrayEfecto];
}
-(void)CargarSonidos
{
NSURL *Imagen1Url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"PrimerSonido"ofType:@"MP3"]];
NSError *error;
Sonido = [[AVAudioPlayer alloc]initWithContentsOfURL:Imagen1Url error:&error];
if (error)
{
NSLog(@"Error in audioPlayer: %@",[error localizedDescription]);
}
else
{
Sonido.delegate = self;
[Sonido prepareToPlay];
}
}
-(IBAction)Animacion1
{
[Sonido play];
[self.imgImagen1 setAnimationRepeatCount:1];
[self.imgImagen1 startAnimating];
}
-(void)audioPlayerDidFinishPlaying:
(AVAudioPlayer *)player successfully:(BOOL)flag
{
}
-(void)audioPlayerDecodeErrorDidOccur:
(AVAudioPlayer *)player error:(NSError *)error
{
}
-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
{
}
-(void)audioPlayerEndInterruption:(AVAudioPlayer *)player
{
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[Sonido stop];
}
-(IBAction)TapOne:(UITapGestureRecognizer *)recognizer
{
[self Animacion1];
}
我正在使用 Xcode 4.6 并且该应用程序适用于 iOS 5.0。我使用带有故事板和模态或推送segue的ARC,我确实尝试以一种简单的方式创建这个应用程序,所以如果你知道一些事情或帮助我,我该如何以更好的方式通过线程或调度来修复或改进这段代码?
并且是的,崩溃日志是:
Incident Identifier: 3B38AB75-8A16-460E-BC07-55F5A0D4D2E6
CrashReporter Key: 3c4dd8277fec52e8c14d73ab348b62650bbf5226
Hardware Model: iPhone3,1
OS Version: iPhone OS 6.1.3 (10B329)
Kernel Version: Darwin Kernel Version 13.0.0: Wed Feb 13 21:36:52 PST 2013; root:xnu-2107.7.55.2.2~1/RELEASE_ARM_S5L8930X
Date: 2013-06-20 10:18:17 -0400
Time since snapshot: 102 ms
Free pages: 1037
Active pages: 3050
Inactive pages: 2264
Throttled pages: 103507
Purgeable pages: 0
Wired pages: 19150
Largest process: Simple Juego Prototipo
Processes
Name <UUID> rpages recent_max [reason] (state)
timed <129ae7acc9bc3209a60ac42d49b0d89f> 290 379 [vm] (daemon) (idle)
Messenger <ee1787e4954037c4a692b76e4d7d4b6e> 1496 2138 [vm] (resume)
MobileSMS <3d75b813ead134998225651ca662356a> 1347 1347 [vm] (background)
MobileMail <e07ca7a7280736c7bf301451f89d1c02> 978 978 [vm] (resume) (continuous)
MobilePhone <51866c9bc9f93c9d8526e8acf9efc64c> 2181 2181 [vm] (continuous)
tccd <2778744d99a530c9a7d5e57a19b60008> 189 189 [vm] (daemon)
kbd <f7341c9a161a39acb5bc18ea47d6ebb7> 499 499 [vm] (daemon)
librariand <5c2a34477ddf3501aed0ec2d25caa09e> 208 208 [vm] (daemon)
Juego Prototipo <63bf4a5a839d3b3fa91700566bff69b3> 88101 88101 [vm] (audio) (frontmost) (resume)
ptpd <096297a7a40f318290a972274cc44d87> 735 735 (daemon)
wifid <72eda25ccdd737a79d6cd172e9bf99a5> 336 336 (daemon)
mediaserverd <af72564bf8713fb8b16ee64c5ee85568> 1004 1004 (daemon)
dataaccessd <abc7f74d5d683d4c9a04e7ade5b1126b> 1237 1237 (daemon)
locationd <137100f254373daeb894f665c413f8b0> 655 655 (daemon)
iaptransportd <9b3cf56b4db13761bbd8ac2e0ff099be> 223 223 (daemon)
syslogd <da215e2d3de133bf8f52590727b9bdfe> 146 146 (daemon)
SpringBoard <bd1d77d154ef3dffbb53d89337c8a08f> 3299 3299
backboardd <e1dc74434e0e3938b17ff0f7ad85d138> 3944 3944 (daemon)
configd <b6a4d70640b63e8f82e0e9f3d6ee2bb9> 449 449 (daemon)
lockdownd <a123aa04ddf83a5fae8e5bc08f0b5771> 248 248 (daemon)
fairplayd.N90 <178af330594b392eab2c7b4499001e75> 143 143 (daemon)
powerd <63673a83ac9c3cf98fdc75df8ba70fd0> 143 143 (daemon)
UserEventAgent <7ee3410c25e4372d84e93318fe42696b> 471 471 (daemon)
debugserver <befb5a346ad43ac1be6790ab46eaceff> 0 0 (daemon)
springboardservi <438ae856a1c039a197e6987a99a8b9b6> 0 0 (daemon)
syncdefaultsd <a18b8aeea66e3ebb9ab0d54e55c1b9d1> 195 195 (daemon)
afcd <3bd960d39c9f3972a10923db0e687b4a> 147 147 (daemon)
syslog_relay <ee47daae952636649230d38b3dc5c2e0> 0 0 (daemon)
notification_pro <08df322fbe7739199f78852a511169ef> 129 129 (daemon)
afcd <3bd960d39c9f3972a10923db0e687b4a> 139 139 (daemon)
ubd <da941d158131359ab82559fdf8b99cb7> 347 347 (daemon)
CVMServer <0944339d86d03b94bf9deda6eecf5642> 72 72 (daemon)
filecoordination <28ca39773e933ed2aa92c117c661d056> 129 129 (daemon)
distnoted <699b8253736233b29180419f139e8c01> 106 106 (daemon)
apsd <5be27dc5ea5234319bc4b47380e42174> 304 304 (daemon)
aggregated <c5a375854c3c31d59548ab53ea86d194> 88 88 (daemon)
networkd <49064febbe553338bd98051399022da4> 181 181 (daemon)
fseventsd <3ea853cb95de3aa48972aa42637af69a> 295 295 (daemon)
BTServer <af0150d5085e326598edff072a23d146> 436 436 (daemon)
imagent <2b64c6111aa63b179a15afd6a76a6696> 420 420 (daemon)
mDNSResponder <1e651badfb7033a68a73a667ec480a08> 210 210 (daemon)
CommCenterClassi <19c784a3f93a35208de01bd47343facc> 637 637 (daemon)
notifyd <67a17b0c297e3785a9e09b8e72f3636a> 186 186 (daemon)
ReportCrash <68e323272a9d37c58ba4cdf1279764c4> 242 352 (daemon)
**End**