PageRenderTime 11ms CodeModel.GetById 8ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/BlocksKit/UIView+BlocksKit.h

http://github.com/zwaldowski/BlocksKit
C++ Header | 94 lines | 10 code | 10 blank | 74 comment | 0 complexity | ec040ac3cb49ad0e7c01d676059b3cea MD5 | raw file
 1//
 2//  UIView+BlocksKit.h
 3//  %PROJECT
 4//
 5
 6#import "BKGlobals.h"
 7
 8/** Convenience on-touch methods for UIView.
 9
10 Includes code by the following:
11
12 - Kevin O'Neill.  <https://github.com/kevinoneill>. 2011. BSD.
13 - Jake Marsh.	 <https://github.com/jakemarsh>.   2011. 
14 - Zach Waldowski. <https://github.com/zwaldowski>.  2011. MIT.
15
16 @warning UIView is only available on iOS or in a Mac app using Chameleon.
17 */
18@interface UIView (BlocksKit)
19
20/** Abstract creation of a block-backed UITapGestureRecognizer.
21
22 This method allows for the recognition of any arbitrary number
23 of fingers tapping any number of times on a view.  An instance
24 of UITapGesture recognizer is allocated for the block and added
25 to the recieving view.
26 
27 @warning This method has an _additive_ effect. Do not call it multiple
28 times to set-up or tear-down. The view will discard the gesture recognizer
29 on release.
30
31 @param numberOfTouches The number of fingers tapping that will trigger the block.
32 @param numberOfTaps The number of taps required to trigger the block.
33 @param block The handler for the UITapGestureRecognizer
34 @see whenTapped:
35 @see whenDoubleTapped:
36 */
37- (void)whenTouches:(NSUInteger)numberOfTouches tapped:(NSUInteger)numberOfTaps handler:(BKBlock)block;
38
39/** Adds a recognizer for one finger tapping once.
40 
41 @warning This method has an _additive_ effect. Do not call it multiple
42 times to set-up or tear-down. The view will discard the gesture recognizer
43 on release.
44
45 @param block The handler for the tap recognizer
46 @see whenDoubleTapped:
47 @see whenTouches:tapped:handler:
48 */
49- (void)whenTapped:(BKBlock)block;
50
51/** Adds a recognizer for one finger tapping twice.
52 
53 @warning This method has an _additive_ effect. Do not call it multiple
54 times to set-up or tear-down. The view will discard the gesture recognizer
55 on release.
56 
57 @param block The handler for the tap recognizer
58 @see whenTapped:
59 @see whenTouches:tapped:handler:
60 */
61- (void)whenDoubleTapped:(BKBlock)block;
62
63/** A convenience wrapper that non-recursively loops through the subviews of a view.
64 
65 @param block A code block that interacts with a UIView sender.
66 */
67- (void)eachSubview:(void(^)(UIView *))block;
68
69/** The block that gets called on a finger down.
70 
71 Internally, this method overrides the touchesBegan:withEvent:
72 selector of UIView and is mechanically similar to
73 UIControlEventTouchDown.
74 */
75@property (nonatomic, copy) BKTouchBlock onTouchDownBlock;
76
77/** The block that gets called on a finger drag.
78 
79 Internally, this method overrides the touchesMoved:withEvent:
80 selector of UIView.
81 
82 @param block The handler for the touch recognizer
83 */
84@property (nonatomic, copy) BKTouchBlock onTouchMoveBlock;
85
86/** The block that gets called on a finger up.
87 
88 Internally, this method overrides the touchesBegan:withEvent:
89 selector of UIView and is mechanically similar to
90 UIControlEventTouchCancel.
91 */
92@property (nonatomic, copy) BKTouchBlock onTouchUpBlock;
93
94@end