I used KVO to observe changes in a frame and set another frame accordingly
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{
if ([keyPath isEqualToString:KeyPathForFrameBeingObserved]) {
[UIView animateWithDuration:1 animations:^{
CGRect frame = [self playWithFrame:viewBeingMonitored.frame];
self.viewToAnimate.frame = frame;
}];
}
}
Code in the animation block is executed but animation is not working, I suspected that repeated calls to animation method could cause this but using log messages I found that animation is not working even for a single call, can anyone explain that ?
iPad 2/(iOS8.4)
- I have tried including the animation method call in
dispatch_async(dispatch_get_main_queue(), ^{ ... });
but animation still not working. - I have tried pushing the observed changes in queue and delaying the animation method for a second using
dispatch_after
to run it only using the last element in the queue to avoid repeated calls but didn't work. - KVO is working perfectly (adding the observer is already handled), but the code in the animation block is executed without animation.