Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dismiss when tap outside the actionsheet #61

Closed
benck opened this issue Nov 20, 2012 · 4 comments
Closed

dismiss when tap outside the actionsheet #61

benck opened this issue Nov 20, 2012 · 4 comments

Comments

@benck
Copy link

benck commented Nov 20, 2012

I fork a project from you and add this function which is very useful. Hope you can add this into master branch.

Simply add a bool property dismissWhenTapOut, and add the following code in the end of "void showActionSheetPicker":

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)];
    if(self.dismissWhenTapOut){
        tap.cancelsTouchesInView = NO;
        [self.actionSheet.superview addGestureRecognizer:tap];
    }
    [tap release];

Finally, add a function inside the same file:

-(void)tapOut:(UIGestureRecognizer *)gestureRecognizer {
    CGPoint p = [gestureRecognizer locationInView:self.actionSheet];
    if (p.y < 0) {
        [self dismissPicker];
    }
}

My branch is here: https://github.com/benck/ActionSheetPicker

@jbierling
Copy link

Why the BOOL dismissWhenTapOut?

@malhal
Copy link

malhal commented Feb 2, 2013

Doesn't keep the selection, it cancels. Also tapping the status bar doesn't dismiss.

@benck
Copy link
Author

benck commented Feb 3, 2013

Because the cancel button is small when a user accidentally makes the actionsheet popup. That's what I meant to do: cancel the selection when tap outside of the actionsheet.

@rwilcox
Copy link

rwilcox commented Mar 10, 2013

There is a better way to do this, using the a UIPopoverController delegate.

If you set _popOverController.delegate = self in AbstractActionSheetPicker's configureAndPresentPopoverForView method, then implement the following method in AbstractActionSheetPicker it should work for you.

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    NSLog(@"Dismissed!!!!");

    [self actionPickerCancel: self];
}

@ma2kubo
Copy link

ma2kubo commented May 27, 2014

Evernote was unable to submit your note for the following reason:

The emailed note was received, but Evernote did not understand the email address. It may have been mistyped, or the user may not exist. Please check to make sure the address was properly entered.

Original message information:
From: Petr Korolev <notifications@github.com>
Delivered To: deviceone.c1297@m.evernote.com
All recipients: TimCinel/ActionSheetPicker <ActionSheetPicker@noreply.github.com>
Subject: Re: [ActionSheetPicker] dismiss when tap outside the actionsheet (#61)

To prevent excessive emails, you may not receive another error reply for the next 360 minutes.

  • The Evernote team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants