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

jacksongan

macrumors member
Original poster
Aug 31, 2009
47
0
Hey guys, here is my code


Code:
	CATransition *transition = [CATransition animation];
	transition.duration = 1.5;
	transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
	transition.type = kCATransitionFade;
	transitioning = YES;
	transition.delegate = self;
	[containerView.layer addAnimation:transition forKey:nil];
	
	view1.hidden = YES;
	view2.hidden = NO;

        CATransition *transition1 = [CATransition animation];
	transition1.duration = 0.5;
	transition1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
	transition1.type = kCATransitionFade;
	transitioning = YES;
	transition1.delegate = self;
	[containerView.layer addAnimation:transition1 forKey:nil];
	
	view2.hidden = YES;
	view3.hidden = NO;

The problem with this code is that the transition performed is the 2nd one. ie. transition1. When i click the animate button, the view jump from view1 to view3, skipping the first transition.

Please help. Thanks!
 
I just did. I would expect that you would no go to the documentation and look for methods that are called when an animation block completes. Anything short of that is just laziness.

So, which documents did you read and what did you discover? I would suggest looking at CATransitions superclass and the obvious delegate methods.
 
well, this is actually part of the Viewtransition sample code from the developer page, with some modifications of course. I dun want to keep pressing button to call for next transition, ie. press once, view1 to view2, press twice, view2 to view3, i jus wana press once to show transition from view1 to view2 followed by view3. I jus cant figure out.
 
well, this is actually part of the Viewtransition sample code from the developer page, with some modifications of course. I dun want to keep pressing button to call for next transition, ie. press once, view1 to view2, press twice, view2 to view3, i jus wana press once to show transition from view1 to view2 followed by view3. I jus cant figure out.

And to do that you will have to use the delegate method I pointed you towards to wait for the end of each transition before starting the next one. This is all the help I will give you: programming is about figuring out solutions for yourself, about using the documentation and about trying things. It's not about copy and pasting code that you ask for as "sample code" and then thinking you know what you are doing or claiming you wrote it yourself.

Go, read, try stuff and actually learn.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.