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

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Hi, Im trying to swip many imageViews in a UIView

Code:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
	if (dirString) 
	{		
		CATransition *animation = [self getAnimation:dirString];
		[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
		//[[self superview] exchangeSubviewAtIndex:currentView withSubviewAtIndex:newView];
		[[[self superview] layer] addAnimation:animation forKey:kAnimationKey];
		
	}
}

This animation code works fine for two subviews. But I am trying to do this for many subviews. I tried by adding a nextView index and currentView index, but nothing.

Example: I have 3 views with index 0, 1 and 2.
//First time, it works, it swips from Index View 2 to 1
[[self superview] exchangeSubviewAtIndex:2 withSubviewAtIndex:1];
//But here, it swips ever the same view with index 1, dont works
[[self superview] exchangeSubviewAtIndex:1 withSubviewAtIndex:0];

and it shoulds to swip after but it fail the previous swip:
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:2];

Any idea to swip several subviews? Thanks for your help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.