views:

98

answers:

1

Hello, 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];
}
A: 

Try adding this:

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

after the line:

[UIView setAnimationDelegate:self];

Also take a look at these: http://stackoverflow.com/questions/630265/iphone-uiview-animation-best-practice http://stackoverflow.com/questions/983598/how-to-animate-view-swap-on-simple-view-iphone-app

Carlos