The runtime sends initialize to each classin a program just before the class, or any class that inherits from it, is sent its first message from within the program. Superclasses receive this message before their subclasses.
The runtime sends the initialize messageto classes in a thread-safe manner. That is, initialize is run by the first thread to send a messageto a class, and any other thread that tries to send a messageto that class will block until initialize completes.
The superclass implementation may be called multiple times if subclasses donot implement initialize—the runtime will call the inheritedimplementation—orif subclasses explicitly call [super initialize]. If you want to protect yourself from being run multiple times, you can structure your implementation along these lines: + (void)initialize { if (self == [ClassName self]) { // ... do the initialization ... } }
Because initialize is called in a blocking manner, it’s important to limit method implementations to the minimum amount of work necessary possible. Specifically, any code that takes locks that might be required by other classes in their initialize methods is liable to lead to deadlocks. Therefore, you should not rely on initialize for complex initialization, and should instead limit it to straightforward, classlocalinitialization.
Special Considerations initialize is invoked only once per class. If you want to perform independent initializationfor the classandfor categories of the class, you should implement load methods.
响应者对象(Responder Object)指的是有响应和处理事件能力的对象。A responder object is any instance of the UIResponder class, and common subclasses include UIView, UIViewController, and UIApplication. UIResponder是所有响应者对象的基类,在UIResponder类中定义了处理上述各种事件的接口。我们熟悉的AppDelegate、UIApplication、 UIViewController、UIWindow和所有继承自UIView的UIKit类都直接或间接的继承自UIResponder,所以它们的实例都是可以构成响应者链的响应者对象。
UIKit uses view-based hit testing to determine where touch events occur. Specifically, UIKit compares the touch location to the bounds of view objects in the view hierarchy. The hitTest:withEvent: method of UIView walks the view hierarchy, looking for the deepest subview that contains the specified touch. That view becomes the first responder for the touch event.
注意:If a touch location is outside of a view’s bounds, the hitTest:withEvent: method ignores that view and all of its subviews. As a result, when a view’s clipsToBounds property is NO, subviews outside of that view’s bounds are not returned even if they happen to contain the touch.
called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating. 因为动画原因滚动结束. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView