我正在使用观察者以下代码
myView = [[UIView alloc] initWithFrame:CGRectZero];
[myView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
另一个代码
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSLog(@"observeValueForKeyPath");
if([keyPath isEqualToString:@"frame"])
{
[self layoutViews];
}
}
但我从来没有得到 Log observeValueForKeyPath