UIControl+YYAdd.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // UIControl+YYAdd.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 13/4/5.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. /**
  13. Provides extensions for `UIControl`.
  14. */
  15. @interface UIControl (YYAdd)
  16. /**
  17. Removes all targets and actions for a particular event (or events)
  18. from an internal dispatch table.
  19. */
  20. - (void)removeAllTargets;
  21. /**
  22. Adds or replaces a target and action for a particular event (or events)
  23. to an internal dispatch table.
  24. @param target The target object—that is, the object to which the
  25. action message is sent. If this is nil, the responder
  26. chain is searched for an object willing to respond to the
  27. action message.
  28. @param action A selector identifying an action message. It cannot be NULL.
  29. @param controlEvents A bitmask specifying the control events for which the
  30. action message is sent.
  31. */
  32. - (void)setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
  33. /**
  34. Adds a block for a particular event (or events) to an internal dispatch table.
  35. It will cause a strong reference to @a block.
  36. @param block The block which is invoked then the action message is
  37. sent (cannot be nil). The block is retained.
  38. @param controlEvents A bitmask specifying the control events for which the
  39. action message is sent.
  40. */
  41. - (void)addBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;
  42. /**
  43. Adds or replaces a block for a particular event (or events) to an internal
  44. dispatch table. It will cause a strong reference to @a block.
  45. @param block The block which is invoked then the action message is
  46. sent (cannot be nil). The block is retained.
  47. @param controlEvents A bitmask specifying the control events for which the
  48. action message is sent.
  49. */
  50. - (void)setBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;
  51. /**
  52. Removes all blocks for a particular event (or events) from an internal
  53. dispatch table.
  54. @param controlEvents A bitmask specifying the control events for which the
  55. action message is sent.
  56. */
  57. - (void)removeAllBlocksForControlEvents:(UIControlEvents)controlEvents;
  58. @end