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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-21-2009, 01:28 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 11
imapps is on a distinguished road
Default UIImageView animation finish notification

Hi all,

I've searched the web and Apple docs for a way to get notified when UIImageView animation finishes but AFAICS there is no way for that.

I have lots of small UIImageViews (about 50-60) each one having the same sequence of PNG images in a NSArray (image001, image002.... image025) and I want to start animating all of them. But I want to be notified when the last one finishes so I can know for sure that all of them finished animating.

Can anyone suggest how to do this easily? If it can't be done with UIImageView, maybe some other way?

Thanks in advance!
imapps is offline   Reply With Quote
Old 07-21-2009, 02:18 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Philadelphia, PA
Posts: 154
dancriel is on a distinguished road
Default

You could use an NSTimer. Every time you begin an image animation, you could invoke something like this:

Code:
setTimerWithInterval:(float)interval {
    [myTimer invalidate];
    myTimer = nil;

    myTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(timerFired) userInfo:nil repeats:NO];
}
This way, any new animations beginning before current animations finish can reset the timer with its own animation duration as the interval, and the timer will only fire when the last animation is complete.

Last edited by dancriel; 07-21-2009 at 04:45 PM.
dancriel is offline   Reply With Quote
Old 07-21-2009, 04:42 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 11
imapps is on a distinguished road
Default

Interesting idea, thanks a lot for taking the time to reply.

Although, I'm worried what would happen if the first (or any other) animation finishes before the next one starts... I'll have to experiment with the numbers.

I'll try this first thing in the morning and let you know how it goes. Thanks again for the tip.
imapps is offline   Reply With Quote
Old 07-21-2009, 05:13 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 11
imapps is on a distinguished road
Default

It seems to have done the trick!

I had to do some extra logic since the timer is accessed from multiple threads so it crashed but once I fixed that it did what I needed.

Thanks man, you saved my day!
imapps is offline   Reply With Quote
Old 07-21-2009, 05:27 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Philadelphia, PA
Posts: 154
dancriel is on a distinguished road
Default

Quote:
Originally Posted by imapps View Post
It seems to have done the trick!

I had to do some extra logic since the timer is accessed from multiple threads so it crashed but once I fixed that it did what I needed.

Thanks man, you saved my day!
No problem

One additional thought occurred to me - you may have already thought about this, but you should probably make sure that your new interval isn't shorter than the remaining time for the existing timer.
dancriel is offline   Reply With Quote
Old 07-22-2009, 03:55 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 11
imapps is on a distinguished road
Default

Yeah, but in my case that can't happen since all the animations have the same duration. Additionally, the timer has a longer firing interval just in case something goes wrong. But thanks for pointing that out.
imapps is offline   Reply With Quote
Old 01-22-2011, 07:31 AM   #7 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 1
neosarchizo is on a distinguished road
Default How about this idea??

How about this??

Firstly add new file .h, and .m

Then write following in header.

@interface TempUIImageView : UIImageView
{ ...

And we check that animation is ended or not by using this class.

I wanna test, but I'm so beginner so I can't...

How about this??
neosarchizo is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
9 members and 314 guests
chiataytuday, coolman, givensur, ipodphone, jbro, mottdog, mtl_tech_guy, Punkjumper, vilisei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,882
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:19 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0