Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding UIResponder by Dirk Smith

Understanding UIResponder by Dirk Smith

Dirk discusses UIResponder at CocoaHeads Durham in July 2012

Triangle Cocoa

July 28, 2012
Tweet

More Decks by Triangle Cocoa

Other Decks in Programming

Transcript

  1. Understanding UIResponder

  2. What is UIResponder? ✤ Basis of many regularly used components:

    UIView, UIViewController, AppDelegate, UIWindow ✤ Important for interacting with the application
  3. UIResponder Core Methods ✤ touchesBegan:withEvent: ✤ touchesMoved:withEvent: ✤ touchesEnded:withEvent: ✤

    touchesCancelled:withEvent: ✤ becomeFirstResponder ✤ canBecomeFirstResponder ✤ canResignFirstResponder ✤ isFirstResponder
  4. UIResponder - First Responder ✤ An object can only become

    a first responder if the existing first responder returns TRUE for canResignFirstResponder and the current object returns TRUE for canBecomeFirstResponder ✤ The default for canResignFirstResponder is TRUE and FALSE for canBecomeFirstResponder ✤ InputView is shown when UIResponder becomes FirstResponder (like a keyboard)
  5. UIResponder Chain

  6. UIResponder Chain ✤ nextResponder defaults to nil; subclasses are responsible

    for determining the next object in the chain ✤ UIView returns its ViewController if its managed by one, or its superview if not ✤ UIViewController returns the UIWindow ✤ UIWindow returns the AppDelegate ✤ Event will be thrown out if not handled
  7. Questions? Magnets, how do they work?

  8. Thanks! My name is Dirk @dirkthedaring dirk@twotoasters.com