Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATransition Undeclared?

I'm trying to initialize a CATransition instance, but xCode keeps telling me that I'm making an Use of undeclared identifier "CATransition". Did you mean "kCATransition"?

The line in question is quite simple:

CATransition* transition = [CATransition animation];

What am I doing wrong? I've found this code several times over the web, but I can't figure out what am I doing different.

EDIT: Ok, so I have imported Quartz like suggested

#import <QuartzCore/QuartzCore.h>

But now I get a different message in the next line of code: "Incompatible pointer to integer conversion sending 'NSString *const' to parameter of type 'NSCellType'"

CATransition* transition = [CATransition animation];
[transition setType:kCATransitionPush];
like image 445
Jaliborc Avatar asked Apr 30 '11 10:04

Jaliborc


2 Answers

#import <QuartzCore/QuartzCore.h>
like image 52
Ole Begemann Avatar answered Jan 01 '23 12:01

Ole Begemann


you definitely need to #import

and here is my example of CATransition :

 - (IBAction)FavButtonPressed:(id)sender
 {

 FavoritesViewController *favVC = [self.storyboard instantiateViewControllerWithIdentifier:@"FavoritesViewController"];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:favVC];



CATransition* transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:nav animated:NO completion:nil];


 }

what this does: transition occurs when I press the favorite button

  1. instantiate the controller I want to transition to : FavoritesViewController (make sure the name defined on the storyboard)
    1. allocate and init the navigation so the nav can be included in the transition
    2. start the animation, determine type: https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CATransition_class/Introduction/Introduction.html
    3. subtype : You want it going from bottom up, top -down, right-left... 6.I want to present nav and I want to say animation: NO which means I do not want it to use default behavior
like image 32
Shana Weitzen Avatar answered Jan 01 '23 12:01

Shana Weitzen