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

alibozorgkhan

macrumors newbie
Original poster
Aug 11, 2009
1
0
Hi everyone
I have created 3 UIViews: Main, Left and Right. I wanna switch between them with changing the Main subviews and I wanna do it with animation. My project works fine but without animation. I wrote my addSubview code after the
[UIView beginAnimations:nil context:Null] and befor the [UIView commitAnimations]. any idea?
 
What else do you have in your animation block to animate the addition of the subviews? Any kinds of frame adjustments? Or something else? Have you considered using the modalTransitionStyle property of UIViewController?
 
Using presentModalViewController:animated: does not help addition of subviews. It is not for adding subviews, but it replaces the main view with the new view and create the parent-child relationship between the ViewControllers, although the switching will look like a new view moving in or fading in animated.

If that is what you want, that is what you do.

However, if you are just adding a new subview on top of another subview and you want the old view to be still visible (i.e. the new subview is semi-transparent or semi-opaque), you use [UIView beginAnimations:nil context:nil] and the [UIView commitAnimations], called an animation block.

However, how you want to use animation blocks, and what you must do to make them work, depends on your exact code. Are the "subviews" simply UIViews added from the Library to the "view" of a UIViewController? Or, are they themselves "views" of UIViewControllers?

More information is needed.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.