I have a UIViewController and in viewDidLoad method, i create a CALayer object and add it to the layer of the controller's view
Here's the output from the console :
From the Core Animation programming guide, it says that :
So i'd like to discuss the followings :
1. Why does [testLayer actionForKey
"transform"] return nil in viewDidLoad, but not nil in viewDidAppear ?
2. In viewDidAppear, all the 'delegate', 'style', 'actions' and 'defaultActionForKey:' are nil. So where does the value of [testLayer actionForKey
"transform"] come from ?
Thanks.
Code:
- (void) viewDidLoad {
[super viewDidLoad];
testLayer = [CALayer layer];
testLayer.frame = CGRectMake(0, 0, 100, 100);
[self.view.layer addSublayer:testLayer];
NSLog(@"In viewDidLoad");
NSLog(@"%@", [testLayer actionForKey:@"transform"]);
NSLog(@"%@", testLayer.delegate);
NSLog(@"%@", testLayer.actions);
NSLog(@"%@", testLayer.style);
NSLog(@"%@", [CALayer defaultActionForKey:@"transform"]);
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"In viewDidAppear");
NSLog(@"%@", [testLayer actionForKey:@"transform"]);
NSLog(@"%@", testLayer.delegate);
NSLog(@"%@", testLayer.actions);
NSLog(@"%@", testLayer.style);
NSLog(@"%@", [CALayer defaultActionForKey:@"transform"]);
}
Here's the output from the console :
Code:
In viewDidLoad
null
null
null
null
null
In viewDidAppear
[B][U]<CABasicAnimation: 0x6d425a0>[/U][/B]
null
null
null
null
From the Core Animation programming guide, it says that :
Code:
When the CALayer implementation of actionForKey: is invoked for an identifier the following search pattern is used:
If the layer has a delegate, and it implements the method actionForLayer:forKey: it is invoked, passing the layer, and the action identifier as parameters. The delegate’s actionForLayer:forKey: implementation should respond as follows:
Return an action object that corresponds to the action identifier.
Return nil if it doesn’t handle the action identifier.
Return NSNull if it doesn’t handle the action identifier and the search should be terminated.
The layer’s actions dictionary is searched for an object that corresponds to the action identifier.
The layer’s style property is searched for an actions dictionary that contains the identifier.
The layer’s class is sent a defaultActionForKey: message. It will return an action object corresponding to the identifier, or nil if not found.
So i'd like to discuss the followings :
1. Why does [testLayer actionForKey
2. In viewDidAppear, all the 'delegate', 'style', 'actions' and 'defaultActionForKey:' are nil. So where does the value of [testLayer actionForKey
Thanks.