Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-27-2009, 07:18 PM   #1 (permalink)
cmpak
Registered Member
 
Join Date: Apr 2009
Location: San Jose, CA
Posts: 22
Question How to change animating iamges with UIImageView

Hi,

I am trying to reuse UIImageView object instead of creating a new one. I am doing so because I found that releasing a UIImageView having animation in the middle before closing the app makes the app crash.

It's because even after stopping a timer (stopAnimating), the timer in the run loop may still point to the already released object depending on the schedule. So I found that releasing a UIImageView which uses a timer object before closing the app is not quite safe. (Correct me if I'm wrong, but that's what I found)

This description from NSTimer class reference explains why:
"The run loop removes and releases the timer, either just before the invalidate method returns or at some later point."

Anyways, how can I change animation images for the existing UIImageView which is currently animating?

stopAnimating itself is ok, but after that if I assign a new array of images, it crashes.

// This crashes the app
[self.imageView stopAnimating];
self.imageView.animationImages = newImageArr;
self.imageView.animationDuration = 0.75; // Duration in seconds
self.imageView.animationRepeatCount = 0; // zero loops forever
[self.imageView startAnimating];

Last edited by cmpak; 04-28-2009 at 04:06 PM.
cmpak is offline   Reply With Quote
 

» Advertisements
» Online Users: 697
22 members and 675 guests
annchavez78, armmzz, at0m87, biskwit, CityBrains, Domele, ilmman, iVenh, katearmine, Macaret, manojb, mayaz7_ayaz, MozyMac, MSJJ, nidie, nik's, qkstrk, rocel1234, s kumar, sacha1996, saqibjaan
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,819
Threads: 89,206
Posts: 380,632
Top Poster: BrianSlick (7,129)
Welcome to our newest member, rocel1234
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.