简体   繁体   中英

iphone App: crashes while running image Animation

in my iphone App i want add Animation which displays images one after another for that

  imgView.animationImages = [NSArray arrayWithObjects: 

                           [UIImage imageNamed:@"image1.png"],
                           [UIImage imageNamed:@"image3.png"],
                           [UIImage imageNamed:@"image5.png"],
                            "
                            "
                           [UIImage imageNamed:@"image150.png"],nil];

imgView.animationDuration = 13.00;
imgView.animationRepeatCount = 1.0;  
[imgView startAnimating]; 

how to manage images to for for smooth Animation and app could run without crash?

i have already compressed my image size.

IMO, since you say that the app is working fine under the simulator and crashes on a device, the most likely cause for the crash is that you are taking too much memory and the OS kills the app (after sending at least one memory warning in my experience).

A very clear sign of it is your app dying without any error messages from the debugger (if you try and run it under the debugger - cmd-Y).

A variant of this behavior is that the OS sends a memory warning, your app unloads some resources (this is done automatically by UIKit for you), and then your app does not find them anymore and crashes. In this case, you should see some meaningful message in the error log.

You could try and reduce the number of images composing your animation to 50 just to see if the crash is there or not; or you could run the app under Instruments to see how memory grows during time and see if the crash is related to a memory peak. By the way: how large are your images? Possibly even 50 could be much...

Another possible reason would be that imgView.animationImages is not retained properly, but I doubt this since you say under the simulator everything works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM