Amit Battan
Amit Battan

Reputation: 3018

observeValueForKeyPath not calling

I am using observer following code

myView = [[UIView alloc] initWithFrame:CGRectZero];
[myView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];

Another Code

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    NSLog(@"observeValueForKeyPath");
    if([keyPath isEqualToString:@"frame"]) 
    {
        [self layoutViews];
    }
}

but I never got the Log observeValueForKeyPath

Upvotes: 3

Views: 1379

Answers (1)

Joshua Pokotilow
Joshua Pokotilow

Reputation: 1223

UIKit isn't consistently KVO-compliant, and you shouldn't take it for granted that properties on UIKit classes are ever KVO-compliant, even if they seem to be through experimentation.

See also: iOS: How do I know if a property is KVO-compliant?

Upvotes: 1

Related Questions