gpt4 book ai didi

iphone - observeValueForKeyPath 未调用

转载 作者:行者123 更新时间:2023-12-03 20:07:56 27 4
gpt4 key购买 nike

我正在使用观察者以下代码

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];
}
}

但我从来没有得到日志observeValueForKeyPath

最佳答案

UIKit 并不始终符合 KVO,并且您不应该想当然地认为 UIKit 类上的属性永远符合 KVO,即使它们似乎是通过实验实现的。 p>

另请参阅:iOS: How do I know if a property is KVO-compliant?

关于iphone - observeValueForKeyPath 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7804113/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com