Switching View Animation

Discussion in 'iOS Development' started by ipodmail09, Sep 7, 2009.

  1. ipodmail09

    ipodmail09 Member

    Joined:
    Mar 13, 2009
    Messages:
    269
    Likes Received:
    0
    Device:
    2G iPod touch
    I have a button witch opens a new view but the transition is not all that nice,
    how do you change the animation ??

    [OBJC]-(IBAction)Cameras

    Please Register or Log in to view images

    id)sender
    {
    Cameras *Cam = [[Cameras alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:Cam animated:YES];
    }[/OBJC]

    I saw this snippet of code and i though it would be great to add it as a transition but to no avail i cant get it to work

    [OBJC][UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:5];
    [UIView setAnimationTransition:110 forView:self.view cache:NO];
    [UIView commitAnimations];[/OBJC]
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I don't mean for this to be condescending, but do you know what "modal" means? More specifically, a modal view controller?

    There is a difference between presenting/dismissing a modal view controller and switching views. A world of difference.

    If you're trying to override the way -presentModalViewController animates the view, then a good place to start would be by actually overridding -presentModalViewController.

    Note, presenting a modal view controller doesn's just shoe a view, it also adds a view controller to the stack, etc.

    Alternatively, look at the code you're using. Just do what you are already doing, but use [whatever presentModalViewController:vc animated:NO]



    If you're trying to switch views, then you need to use a container view. Feed the container view to that that animation method I posted that you quoted, remove the current subview if te container and add another subview to the container. It's that simple.

Share This Page