0

I would like to have a category for UIViewController containing few simple methods to move the view controller's view around, fading it etc...

For example the method below fades in/out a the VC's view. I'm not using instance variables and the onTransitionIn: method is called, the problem is the view doesn't fade in/out.

Can someone tell me what I'm doing wrong?

Thank you!

EXAMPLE:

@implementation UIViewController (UIViewControllerAdditions)

- (void)onTransitionIn:(BOOL)isIn {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:ANIM_DUR];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDelegate:self];

    int newAlpha = 1;
    if (!isIn) {
        newAlpha = 0;
        [UIView setAnimationDidStopSelector:@selector(hideAnimationDidStop)];
    }

    // set the new alpha
    self.view.alpha = newAlpha; 
    [UIView commitAnimations];
}
coneybeare
  • 33,113
  • 21
  • 131
  • 183
powpow
  • 1
  • 1

1 Answers1

0

Try adding this:

[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: self.view cache:YES];

after the line:

[UIView setAnimationDelegate:self];

Also take a look at these: iPhone UIView Animation Best Practice How to animate View swap on simple View iPhone App?

Community
  • 1
  • 1
Carlos
  • 1,696
  • 1
  • 14
  • 21