Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在viewController中使用CATTransition_Iphone_Objective C_Debugging_Quartz Graphics - Fatal编程技术网

Iphone 在viewController中使用CATTransition

Iphone 在viewController中使用CATTransition,iphone,objective-c,debugging,quartz-graphics,Iphone,Objective C,Debugging,Quartz Graphics,我试图实现来自Apple的ViewTransitions代码示例,但将所有逻辑放在我的viewController中,而不是我的ApplicationLegate类中 当我试图编译时,我遇到了一个奇怪的错误 _kCATransitionFade", referenced from: _kCATransitionFade$non_lazy_ptr in ViewTransitionsAsViewControllerViewController.o (maybe you meant: _kCA

我试图实现来自Apple的ViewTransitions代码示例,但将所有逻辑放在我的viewController中,而不是我的ApplicationLegate类中

当我试图编译时,我遇到了一个奇怪的错误

_kCATransitionFade", referenced from:
  _kCATransitionFade$non_lazy_ptr in ViewTransitionsAsViewControllerViewController.o
 (maybe you meant: _kCATransitionFade$non_lazy_ptr)
有人有什么想法吗

回答第一条评论,这是我的整个viewController实现。与Apple ViewTransitions代码的唯一真正区别在于,我正在将逻辑从“ApplicationIDFinishLaunching”方法移动到“viewDidLoad”方法

#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

您需要将QuartzCore.framework添加到目标中

1扩大目标 2选择要配置的应用程序 3 Cmd+I/获取信息 4在“链接库”部分下,按+按钮并从列表中选择QuartzCore.framework


您现在应该可以编译了。

发布代码,特别是设置转换的区域,会对您有所帮助。