addSubview Animation

Discussion in 'iOS Programming' started by alibozorgkhan, Aug 11, 2009.

  1. alibozorgkhan macrumors newbie

    Joined:
    Aug 11, 2009
    #1
    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?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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?
     
  3. yoichi00 macrumors newbie

    Joined:
    Feb 13, 2010
    #3
    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.
     

Share This Page