3

I have a custom UIView which is an accessibility container. Each of the UIAccessibilityElements it houses has a frame, relative to the window. Because the frame is relative to the window, it needs to be updated whenever the position of the view in the window changes.

Is there a way to be notified when the position of the view in the window changes? This would allow me to keep all the code in this class, nice and reusable, instead of sprawling all over the view hierarchy.

Charles
  • 50,943
  • 13
  • 104
  • 142
Hilton Campbell
  • 6,065
  • 3
  • 47
  • 79
  • Not sure whether I understood the problem correctly, but you can do KVO stuff with any views frame. [view1 addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:NULL]; – Srikanth Dec 12 '12 at 02:47
  • 2
    Right, you can monitor the frame, but that won't catch changes in the view's position on the screen if, say, it's superview's frame changes. – Hilton Campbell Dec 12 '12 at 02:57

1 Answers1

1

Here Introduction to Key-Value Observing Programming Guide

KVO can monitor UIView's frame changed.

lumingjing
  • 390
  • 2
  • 10
  • 3
    You can use KVO to monitor the frame, but that won't catch changes in the view's position on the screen if, say, its superview's frame changes. – Hilton Campbell Dec 12 '12 at 03:19