views:

70

answers:

1

I am presenting a UIActionSheet when a user double taps my cell:

Tap Recognition in Cell Init:

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]
                                            initWithTarget:self 
                                             action:@selector(handleDoubleTap:)];

        [doubleTap setNumberOfTapsRequired:2];
        [self addGestureRecognizer:doubleTap];
        [doubleTap release];

Tell the delegate to handle the tap:

- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer {
    NSLog(@"double oo");
    [delegate handleDoubleTapp];
}

Now the delegate which is my UITableViewController will present the UIActionSheet:

-(void)handleDoubleTapp{

        UIActionSheet *actionSheet = [[[UIActionSheet alloc]
                                       initWithTitle:nil
                                       delegate:self
                                       cancelButtonTitle:@"Cancel"
                                       destructiveButtonTitle:nil
                                       otherButtonTitles:@"Reply", @"Retweet", @"Direct Message", nil] autorelease];    
        [actionSheet showInView:self.parentViewController.tabBarController.view];

    }   
}

My UITableViewController implements the UIActionSheet delegate methods properly.

Problems:

  1. Not all areas of the actionsheet are responsive
  2. Clicking on a button presents a modal view, but the actionsheet does not get dismissed
  3. When buttons are able to be clicked, they don't highlight
A: 

Just as a thought: did you try unregistering the UIGestureRecognizer once the UIActionSheet is about to become visible and re-registering it when the action sheet is dismissed? Maybe the recognizer is interfering with the touches.

Benjamin
How can I unregister the recognizer?
Sheehan Alam
I added: [recognizer removeTarget:nil action:NULL]; in handleDoubleTap. This fixed the problem, however after I double click on a cell once, I can't double click on it again. Where is the right place to unregister? Where is the right place to register?
Sheehan Alam
Instead of removing, I just set the enabled state to false. Re-enabled it in the delegate after the action sheet displayed. Great tip.
Sheehan Alam
Perfect - I'm glad I was able to point you in the right direction. Good find regarding enabled / disabled state instead of adding / removing!
Benjamin