Created
May 30, 2011 05:34
-
-
Save chrishulbert/998492 to your computer and use it in GitHub Desktop.
Allow closing a UIActionSheet by tapping above it, in the shaded area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For detecting taps outside of the alert view | |
-(void)tapOut:(UIGestureRecognizer *)gestureRecognizer { | |
CGPoint p = [gestureRecognizer locationInView:self]; | |
if (p.y < 0) { // They tapped outside | |
[self dismissWithClickedButtonIndex:0 animated:YES]; | |
} | |
} | |
-(void) showFromTabBar:(UITabBar *)view { | |
[super showFromTabBar:view]; | |
// Capture taps outside the bounds of this alert view | |
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)]; | |
tap.cancelsTouchesInView = NO; // So that legit taps on the table bubble up to the tableview | |
[self.superview addGestureRecognizer:tap]; | |
[tap release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment