Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RossOliver

macrumors regular
Original poster
Nov 6, 2006
157
0
Hey,

I've been playing around with the UIShowcase example and swiped the flipImage method, modifying it to flip to a specified image:

Code:
-( void )flipToImage:( UIImage * )image
{
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:TRANSITION_DURATION];
	[UIView setAnimationTransition:( UIViewAnimationTransitionFlipFromLeft ) forView:containerView cache:NO];

	if( [secondImageView superview] )
	{
		firstImageView.image = image;
		[secondImageView removeFromSuperview];
		[containerView addSubview:firstImageView];
	}
	else
	{
		secondImageView.image = image;
		[firstImageView removeFromSuperview];
		[containerView addSubview:secondImageView];
	}
	[UIView commitAnimations];
}

I then want to do two flips in succession, so the first flip is done and when that has finished the second flip is done:

Code:
-( void )processImage:( UIImage * )image
{
	[self flipToImage:image];
        // CONTACT WEB SERVER WHICH TAKES A RANDOM AMOUNT OF TIME
	[self flipToImage:NO_IMAGE];	
}

The problem I have is that only the second flip to NO_IMAGE is happening because as soon as it is called it stops the first flip to image. Is there any way to turn of the asynchronous behaviour of the flipToImage method? Usually an outer method waits until it has finished executing a submethod...

I'm fairly sure I could create some delegate methods to respond to a setAnimationDidStopSelector message, but I want to do some processing for a random amount of time between the first and second image flip, so waiting for the first to finish flipping before I start processing is a waste of time...

Thanks for your time,

-Ross
 

jasamer

macrumors newbie
Apr 14, 2008
2
0
I think it'll be best to use setAnimationDidStopSelector as you said and put the time-consuming processing in a new thread.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.