Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions JMWhenTapped/UIView+WhenTappedBlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef void (^JMWhenTappedBlock)();
- (void)whenTwoFingerTapped:(JMWhenTappedBlock)block;
- (void)whenTouchedDown:(JMWhenTappedBlock)block;
- (void)whenTouchedUp:(JMWhenTappedBlock)block;
- (void)whenTapCanceled:(JMWhenTappedBlock)block;

@end

Expand Down
10 changes: 10 additions & 0 deletions JMWhenTapped/UIView+WhenTappedBlocks.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ @implementation UIView (JMWhenTappedBlocks)
static char kWhenTwoFingerTappedBlockKey;
static char kWhenTouchedDownBlockKey;
static char kWhenTouchedUpBlockKey;
static char kWhenTapCanceledKey;

#pragma mark -
#pragma mark Set blocks
Expand Down Expand Up @@ -73,6 +74,10 @@ - (void)whenTouchedUp:(JMWhenTappedBlock)block {
[self setBlock:block forKey:&kWhenTouchedUpBlockKey];
}

- (void)whenTapCanceled:(JMWhenTappedBlock)block {
[self setBlock:block forKey:&kWhenTapCanceledKey];
}

#pragma mark -
#pragma mark Callbacks

Expand All @@ -93,6 +98,11 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self runBlockForKey:&kWhenTouchedDownBlockKey];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];
[self runBlockForKey:&kWhenTapCanceledKey];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self runBlockForKey:&kWhenTouchedUpBlockKey];
Expand Down
4 changes: 4 additions & 0 deletions JMWhenTappedDemo/JMWhenTappedDemo/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ - (void) loadView {
otherButtonTitles:nil];
[a show];
}];

[self.view2 whenTapCanceled:^{
NSLog(@" tap canceled ");
}];

}

Expand Down