One Quickie


Adding a long-press to a UITableViewCell that pops up a UIMenuController (UITableView->General)
To add a long-press that pops up a UIMenuController, You'll need to subclass UITableViewCell, but you're probably already doing that. Add the gesture recognizer, and a notification handler that'll unselect the cell:
        UILongPressGestureRecognizer *longPressGesture =
            [[[UILongPressGestureRecognizer alloc] initWithTarget: self
                                                   action: @selector(longPress:)]
                autorelease];
        [self addGestureRecognizer: longPressGesture];

        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver: self
                selector: @selector(unselectSelf:)
                name: UIMenuControllerWillHideMenuNotification
                object: nil];

- (void) unselectSelf: (NSNotification *) notification {
    self.selected = NO;
} // unselectSelf
In the long press handler, check the state (to prevent multiple firings of the gesture recognizer from making the menus spaz out), and then set up the menu thing.
- (void) longPress: (UILongPressGestureRecognizer *) recognizer {

    if (recognizer.state != UIGestureRecognizerStateBegan) return;

    Put the stuff from  Adding a pop up menu thingie here

    self.selected = YES;  // Highlight to make it doubly-obvious what's being menu'd

} // longPress



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com