Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-12-2009, 04:55 PM   #1 (permalink)
New Member
 
Join Date: May 2009
Posts: 3
dimaco is on a distinguished road
Default layer.anchorPoint won't animate

Hello everyone,
I'm a newbie Iphone Developer and I came here with a question, which I've been googling all day for an answer.

Consider the following code:
Code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:10];
pageBack.layer.position = CGPointMake(320.0, 460.0);
pageBack.layer.anchorPoint = CGPointMake(0.0, 1.0);
pageBack.layer.opacity = 0.0;
[pageBack.layer setValue:[NSNumber numberWithFloat:[self degrees2Radians:90.0]] forKeyPath:@"transform.rotation.z"];
[UIView commitAnimations];
Everything works just fine except for one property of the layer: anchorPoint. It looks like it directly jumps to the CGPoint with no animation. Event with a very slow duration (I've set it to 10) the layer instantly gets that anchorPoint with no transition. It's driving me crazy. Am I doing something stupid there? Apple Documentation says that property is animatable!

Thanks in advance for any help/explanation.
Giorgio
dimaco is offline   Reply With Quote
Old 05-13-2009, 07:18 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 5
ivico92 is on a distinguished road
Default

Hi, I don't know for your non-transition problem cuz I have the same problem.
Did you find the reason ?
(I have a scale transform coupled with a translate transform animation, and the scale jumps cut directly to the final value...)
ivico92 is offline   Reply With Quote
Old 05-13-2009, 08:02 AM   #3 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

Hi Dimaco,

You will have to animate the anchor point too. Below is an updation to your code. Hope it will solve your problem.


Code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5];
pageBack.layer.position = CGPointMake(320.0, 460.0);

// Animate the anchor point	
CABasicAnimation *theAnimation = [CABasicAnimation animationWithKeyPath:@"anchorPoint"];
theAnimation.duration = 1.0;
theAnimation.fromValue = [NSValue valueWithPoint:NSMakePoint(pageBack.layer.anchorPoint.x, pageBack.layer.anchorPoint.y)];	
theAnimation.toValue = [NSValue valueWithPoint:NSMakePoint(0.0, 1.0)];
[pageBack.layer addAnimation:theAnimation forKey:@"anchorPoint"];
pageBack.layer.anchorPoint = CGPointMake(0.0, 1.0);
// end
	
pageBack.layer.opacity = 0.0;
[pageBack.layer setValue:[NSNumber numberWithFloat:[self degrees2Radians:90.0]] forKeyPath:@"transform.rotation.z"];
[UIView commitAnimations];
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-13-2009, 01:33 PM   #4 (permalink)
New Member
 
Join Date: May 2009
Posts: 3
dimaco is on a distinguished road
Default

Quote:
Originally Posted by sukumar_77 View Post
Hi Dimaco,
You will have to animate the anchor point too. Below is an updation to your code. Hope it will solve your problem.
Code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5];
pageBack.layer.position = CGPointMake(320.0, 460.0);
// Animate the anchor point	
CABasicAnimation *theAnimation = [CABasicAnimation animationWithKeyPath:@"anchorPoint"];
theAnimation.duration = 1.0;
theAnimation.fromValue = [NSValue valueWithPoint:NSMakePoint(pageBack.layer.anchorPoint.x, pageBack.layer.anchorPoint.y)];	
theAnimation.toValue = [NSValue valueWithPoint:NSMakePoint(0.0, 1.0)];
[pageBack.layer addAnimation:theAnimation forKey:@"anchorPoint"];
pageBack.layer.anchorPoint = CGPointMake(0.0, 1.0);
// end	
pageBack.layer.opacity = 0.0;
[pageBack.layer setValue:[NSNumber numberWithFloat:[self degrees2Radians:90.0]] forKeyPath:@"transform.rotation.z"];
[UIView commitAnimations];
thank you for the code
would you please tell me what library I've got to include? I get the following error:
Code:
Undefined symbols:
  "_NSMakePoint", referenced from:
      -[PageController cancelAnimation] in PageController.o
      -[PageController cancelAnimation] in PageController.o
  ".objc_class_name_CABasicAnimation", referenced from:
      literal-pointer@__OBJC@__cls_refs@CABasicAnimation in PageController.o
symbol(s) not found
collect2: ld returned 1 exit status
Build failed (2 errors, 3 warnings)
Still I have included the whole QuartsCore
#import <QuartzCore/QuartzCore.h>;

Thank you very much for your time!
Giorgio
dimaco is offline   Reply With Quote
Old 05-14-2009, 12:24 AM   #5 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

Just check for Foundation framework.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-14-2009, 08:26 AM   #6 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

This is just an update to my own post.

Please use the following updated code. The api used previously are not available in iPhone OS.

Code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5];
imgView.layer.position = CGPointMake(320.0, 460.0);
	
CABasicAnimation *theAnimation = [CABasicAnimation animationWithKeyPath:@"anchorPoint"];
theAnimation.duration = 1.0;
	
CGPoint fromPoint = CGPointMake(imgView.layer.anchorPoint.x, imgView.layer.anchorPoint.y);
CGPoint toPoint = CGPointMake(0.0, 1.0);
	
theAnimation.fromValue = [NSValue valueWithBytes:&fromPoint objCType:@encode(CGPoint)];	
theAnimation.toValue = [NSValue valueWithBytes:&toPoint objCType:@encode(CGPoint)];
[imgView.layer addAnimation:theAnimation forKey:@"anchorPoint"];
imgView.layer.anchorPoint = CGPointMake(0.0, 1.0);
	
	
imgView.layer.opacity = 0.0;
[imgView.layer setValue:[NSNumber numberWithFloat:90.0*(M_PI/180)] forKeyPath:@"transform.rotation.z"];
[UIView commitAnimations];
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-14-2009, 05:33 PM   #7 (permalink)
New Member
 
Join Date: May 2009
Posts: 3
dimaco is on a distinguished road
Default

Quote:
Originally Posted by sukumar_77 View Post
This is just an update to my own post.
Please use the following updated code. The api used previously are not available in iPhone OS.
Hi sukumar,
thanks again for your replies
Unfortunately, even with your second code I get the following error:
Code:
".objc_class_name_CABasicAnimation", referenced from:
      literal-pointer@__OBJC@__cls_refs@CABasicAnimation in PageController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I tried, as you suggested, to include <Foundation/Foundation.h> but it didn't help...
There is any other library I should include?
Thank you very much
I appreciate your patience!

Giorgio
dimaco is offline   Reply With Quote
Old 05-14-2009, 11:48 PM   #8 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

When you create a new Xcode project, the template include three frameworks viz. Foundation, UIKit and CoreGraphics.

I have just added QuartzCore and nothing more. This time error might be coming due to one of the missing header file. Don't know what exactly is happening.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 06-16-2009, 04:18 AM   #9 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 1
Alexander is on a distinguished road
Default

Quote:
Originally Posted by dimaco View Post
Hi sukumar,
thanks again for your replies
Unfortunately, even with your second code I get the following error:
Code:
".objc_class_name_CABasicAnimation", referenced from:
      literal-pointer@__OBJC@__cls_refs@CABasicAnimation in PageController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Giorgio
You need to add QuartzCore.framework (/System/Library/Frameworks/QuartzCore.framework) into your project in Xcode.
Alexander is offline   Reply With Quote
Old 06-16-2009, 09:41 AM   #10 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 203
sukumar_77 is on a distinguished road
Default

Quote:
Originally Posted by Alexander View Post
You need to add QuartzCore.framework (/System/Library/Frameworks/QuartzCore.framework) into your project in Xcode.
The correct path is /Developer/Platforms/YOUR_PLATFORM(SIMULATOR/IPHONE)/Developer/SDKs/YOURSDK(2.0/2.1/2.2/3.0)/System/Library/Frameworks/QuartzCore.framework.

Just do not get confuse with System (Mac OS X) path.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Reply

Bookmarks

Tags
anchorpoint, animate, animation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 360
9 members and 351 guests
.Snipe, BSH, Cee Oasis, givensur, guusleijsten, HemiMG, NSString, Paul Slocum, SillyHoney
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:24 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0