Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:02:01+00:00 2026-06-04T08:02:01+00:00

In Keynote (and other apps), I’ve noticed the standard interface of doing Undo/Redo is

  • 0

In Keynote (and other apps), I’ve noticed the “standard” interface of doing Undo/Redo is by providing an Undo button on the tool bar.

Clicking the button (that is always enabled) Undos the recent operation.
(If there is not recent operation to undo, it will show the Undo/Redo menu).

Long-clicking the Undo button opens an Undo/Redo menu.

I searched for methods of implementing this, and the best answer I found so far is at the following link.

I wonder if anyone knows of a simpler way?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:02:03+00:00Added an answer on June 4, 2026 at 8:02 am

    After reviewing all methods and discussing with friends, below is the solution I used, for a UIBarButtonItem the responds to both taps and long-press (TapOrLongPressBarButtonItem).

    It is based on the following principals:

    1. Subclass UIBarButtonItem
    2. Use a custom view (so it’s really trivial to handle the long-press – since our custom view has no problem responding to a long-press gesture handler…)

    … So far – this approach was in the other SO thread – and I didn’t like this approach since I couldn’t find and easy enough way of making the custom view appear like an iPad navigation bar button… Soooo…

    Use UIGlossyButton by Water Lou (thanks water!). This use is encapsulated within the subclass…

    The resulting code is as follows:

    @protocol TapOrPressButtonDelegate;
    @interface TapOrPressBarButtonItem : UIBarButtonItem {  
        UIGlossyButton* _tapOrPressButton;
        __weak id<TapOrPressButtonDelegate> _delegate;
    }
    - (id)initWithTitle:(NSString*)title andDelegate:(id<TapOrPressButtonDelegate>)delegate;
    @end
    
    @protocol TapOrPressButtonDelegate<NSObject>
    - (void)buttonTapped:(UIButton*)button withBarButtonItem:(UIBarButtonItem*)barButtonItem;
    - (void)buttonLongPressed:(UIButton*)button withBarButtonItem:(UIBarButtonItem*)barButtonItem;
    @end
    
    @implementation TapOrPressBarButtonItem
    - (void)buttonLongPressed:(UILongPressGestureRecognizer*)gesture {
        if (gesture.state != UIGestureRecognizerStateBegan)
            return;
        if([_delegate respondsToSelector:@selector(buttonLongPressed:withBarButtonItem:)]) {
            [_delegate buttonLongPressed:_tapOrPressButton withBarButtonItem:self];
        }
    }
    
    - (void)buttonTapped:(id)sender {
        if (sender != _tapOrPressButton) {
            return;
        }
    
        if([_delegate respondsToSelector:@selector(buttonTapped:withBarButtonItem:)]) {
            [_delegate buttonTapped:_tapOrPressButton withBarButtonItem:self];
        }   
    }
    
    - (id)initWithTitle:(NSString*)title andDelegate:(id<TapOrPressButtonDelegate>)delegate {
        if (self = [super init]) {
            // Store delegate reference
            _delegate = delegate;
    
            // Create the customm button that will have the iPad-nav-bar-default appearance 
            _tapOrPressButton = [UIGlossyButton buttonWithType:UIButtonTypeCustom];
            [_tapOrPressButton setTitle:title forState:UIControlStateNormal];
            [_tapOrPressButton setNavigationButtonWithColor:[UIColor colorWithRed:123.0/255 green:130.0/255 blue:139.0/255 alpha:1.0]];
            // Calculate width...
            CGSize labelSize = CGSizeMake(1000, 30);
            labelSize = [title sizeWithFont:_tapOrPressButton.titleLabel.font constrainedToSize:labelSize lineBreakMode:UILineBreakModeMiddleTruncation];
            _tapOrPressButton.frame = CGRectMake(0, 0, labelSize.width+20, 30);
    
            // Add a handler for a tap
            [_tapOrPressButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
            // Add a handler for a long-press
            UILongPressGestureRecognizer* buttonLongPress_ = [[UILongPressGestureRecognizer alloc] initWithTarget:self
                                                                                                           action:@selector(buttonLongPressed:)];
            [_tapOrPressButton addGestureRecognizer:buttonLongPress_];
    
            // Set this button as the custom view of the bar item...
            self.customView = _tapOrPressButton;
        }
        return self;
    }
    
    // Safe guards...
    - (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action {
        NSLog(@"%s not supported!", __FUNCTION__);
        return nil;
    }
    
    - (id)initWithImage:(UIImage *)image landscapeImagePhone:(UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action {
        NSLog(@"%s not supported!", __FUNCTION__);
        return nil;
    }
    
    - (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action {
        NSLog(@"%s not supported!", __FUNCTION__);
        return nil;
    }
    - (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action {
        NSLog(@"%s not supported!", __FUNCTION__);
        return nil;
    }
    
    - (id)initWithCustomView:(UIView *)customView {
        NSLog(@"%s not supported!", __FUNCTION__);
        return nil;
    }
    
    @end
    

    And all you need to do is:

    1. Instantiate is as follows:

    TapOrPressBarButtonItem* undoMenuButton = [[TapOrPressBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Undo", @"Undo Menu Title") andDelegate:self];

    2. Connect the button to the navigation bar:

    [self.navigationItem setLeftBarButtonItem:undoMenuButton animated:NO];

    3. Implement the TapOrPressButtonDelegate protocol, and you’re done…

    -(void)buttonTapped:(UIButton*)button withBarButtonItem:(UIBarButtonItem*)barButtonItem {
        [self menuItemUndo:barButtonItem];
    }
    
    -(void)buttonLongPressed:(UIButton*)button withBarButtonItem:(UIBarButtonItem*)barButtonItem {
        [self undoMenuClicked:barButtonItem];
    }

    Hope this helps anyone else…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was watching today's Microsoft's Keynote at CES 2012 and noticed the demonstrator searching
I have noticed jQuery and related keynote plugins like jQuery.UI pass undefined as a
the app I want to create will have an interface very like Keynote, with
I'm trying to batch convert a bunch of assorted iWork files (Numbers, Pages, Keynote)
In Steve Jobs' keynote announcement of the iPhone SDK 4 earlier this year, one
Some context: I am building a tool to be used on screen during a
I noticed that in Jeff's slides Challenges in Building Large-Scale Information Retrieval Systems, which
All, How can I use (NS)Views from other applications as Layers in my CA
Lately I have been creating PowerPoint presentations to companies. I have mostly been doing
I just saw Bret Victors Keynote called Inventing on Principle. At around 3:34 Minutes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.