À l'aide de CATransition dans un viewController

Je suis en train de mettre en œuvre les ViewTransitions exemple de code à partir d'Apple, mais de mettre de la logique dans mon viewController à la place de mon applicationDelegate classe.

Je suis un bizarre d'erreur lorsque j'essaie de compiler.

_kCATransitionFade", referenced from:
  _kCATransitionFade$non_lazy_ptr in ViewTransitionsAsViewControllerViewController.o
 (maybe you meant: _kCATransitionFade$non_lazy_ptr)

Quelqu'un a des idées?

Répondre le 1er commentaire, c'est toute ma viewController mise en œuvre. La seule vraie différence à partir de l'Apple ViewTranstions code, c'est que je suis passer de la logique de la "applicationDidFinishLaunching' méthode à ma "viewDidLoad" la méthode.

#import "ViewTransitionsAsViewControllerViewController.h"
#import <QuartzCore/QuartzCore.h>
@implementation ViewTransitionsAsViewControllerViewController
@synthesize containerView, doTransitionButton;
//Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {  
UIImage *image1 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image1.jpg" ofType:nil]];
view1 = [[UIImageView alloc] initWithImage:image1];
UIImage *image2 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image2.jpg" ofType:nil]];
view2 = [[UIImageView alloc] initWithImage:image2];
view2.hidden = YES;
[containerView addSubview:view1];
[containerView addSubview:view2];
transitioning = NO;
[super viewDidLoad];
}
//Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)dealloc
{
[containerView release];
[view1 release];
[view2 release];
[super dealloc];
}
-(void)performTransition
{ 
//First create a CATransition object to describe the transition
CATransition *transition = [CATransition animation];
transition.duration = 0.05;
transition.timingFunction = [CAMediaTimingFunction      
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type =kCATransitionFade;
transitioning = YES;
transition.delegate = self;
//Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[containerView.layer addAnimation:transition forKey:nil];
//Here we hide view1, and show view2, which will cause Core Animation to animate view1 away and view2 in.
view1.hidden = YES;
view2.hidden = NO;
//And so that we will continue to swap between our two images, we swap the instance variables     referencing them.
UIImageView *tmp = view2;
view2 = view1;
view1 = tmp;
}
-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
transitioning = NO;
}
-(IBAction) doTransition:(id)sender
{
if(!transitioning)
{
[self performTransition];
}
}
@end
  • Il serait pour vous aider à publier votre code, en particulier la région dans laquelle vous êtes en train de configurer les transitions.
InformationsquelleAutor Bachalo | 2010-06-06