Animating views in iPhone

Discussion in 'Mac Programming' started by sujithkrishnan, May 22, 2008.

  1. macrumors 6502

    May 9, 2008
    Hi all..

    I am making use of the following code in my iphone app to make an animation of the particular view.
    This code works pretty good in viewDidAppear method, but not in viewWillAppear method and loadView method , Why so???

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.75];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [UIView commitAnimations];

    Also i want to display the view with animation, here what happen is that the view will appear and then go for an animation.

    The app what i am trying to developing should lokks like each views are each side of a cube...

    help me!!!!
  2. macrumors 6502a


    Jan 4, 2002
    Austin, TX
    The viewWillAppear method and loadView method are to let your program setup any objects or data you need before the view is shown.

    There is a lot of really helpful sample code from Apple that covers all of the basic tasks for making a new iPhone program.

    This one deals with transitioning views:

    Part of the learning Cocoa is learning where you insert your own code on top of the framework to do something different for your program. In Apple's sample code they create a custom subclass of the UIView and use that to manage transitions to other subviews.

    Once you understand that you are simply adding a few custom pieces to the existing large frameworks in iPhone OS X you will more easily figure out how to make your iPhone program (or Mac cocoa program).
  3. macrumors regular

    Mar 27, 2008
    viewDidAppear is basically after all objects and instances have been allocated and initialized for that view and right before it "releases" the view to be seen in the UI, it fires off one last event handler.

    The other 2 are before and during events. Those are probably not working as well/not at all because the objects you are relying on probably are not completely initialized yet.

Share This Page