views:

362

answers:

1

I'm interested in running some methods when my UIView is changed, either through a frame change or an affine transformation. My best idea is to do this by observing value changes for:

myView.frame and myView.transform.

However, the view portion of UIViews is not Key-Value complaint. Fortunatly the model portion of the view, the CALayer is. So I setup like:

    [self.layer addObserver:self forKeyPath:@"transform" 
options:(NSKeyValueObservingOptionNew) context:NULL];

In the viewDidLoad: portion of the view. I've done the same for the "frame" key. But when the view is changed, either by moving the view around in it's super view, or by affine transformations, the method:

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
 change:(NSDictionary *)change context:(void *)context {

is never called. What gives? Is there a better way to observe changes in a UIViews frame and transform?

A: 

I don't KVC compliance implies KVO compliance. I think I read that KVO is not available for CALayer properties due to performance considerations.

charshep

related questions