iOS: добавить наблюдателя в frame.origin.y из UIView?

Я пытаюсь отслеживать и реагировать на изменение значения происхождения фрейма UIView. Мой код:

[cell.bottomView addObserver:self forKeyPath:@"frame.origin" options:NSKeyValueObservingOptionNew context:NULL];

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    NSLog(@"%@ Changed", keyPath);
}


I'm getting the following error message that I don't understand:

An instance 0x7587d10 of class NSConcreteValue was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x7587fd0> (
<NSKeyValueObservance 0x7587f70: Observer: 0x7587bd0, Key path: origin, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x7587ff0>
)

Really, I'm only interested in the y position of the origin but the code won't even compile if I set the keyPath to "frame.origin.y".

If I set the keyPath to simply "frame", there are no errors but the method observeValueForKeyPath never gets called. I guess a change to a frame's origin doesn't count as a change to the frame..?

How do I accomplish adding an observer to a UIView's frame.origin.y ?

Ответы на вопрос(3)

Ваш ответ на вопрос