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 9007199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:37:27+00:00 2026-06-16T01:37:27+00:00

I recently added to my app the ability to long-press on a UILabel inside

  • 0

I recently added to my app the ability to long-press on a UILabel inside a table cell to make the “Copy” menu appear so the user can copy the text to the pasteboard. It works great both in the simulator and when I build directly to a device. However, when I build & archive (so I can push to TestFlight) the feature does not work.

I attempted the solution in this Stack Overflow question but it didn’t work (and doesn’t seem relevant since I’m building for iOS 5.0+). I have Optimization Level set to None [-O0] in Build Settings.

  1. How can I debug what’s failing if it works fine in Xcode? (IE, is the Gesture Recognizer not working, or the UIMenuController, etc.)
  2. Why is the Archive copy behaving differently than the build-to-device copy?

Here’s the relevant code (although I’m 90% sure the issue is not this code but some Xcode setting):

Adding the Gesture Recognizer:

UIGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                              initWithTarget:self action:@selector(handleLongPressForCopy:)];
[_postLabel addGestureRecognizer:longPress];            
[self addSubview:_postLabel];

Handle Long Press

- (void)handleLongPressForCopy:(UILongPressGestureRecognizer *)recognizer {
    switch (recognizer.state) {
        case UIGestureRecognizerStateBegan:            
            NSAssert([self becomeFirstResponder], @"Sorry, UIMenuController will not work with %@ since it cannot become first responder", self);
            UIMenuController *theMenu = [UIMenuController sharedMenuController];
            CGRect displayRect = CGRectMake(_postLabel.frame.origin.x, _postLabel.frame.origin.y, 10, 0);
            [theMenu setTargetRect:displayRect inView:self];
            [theMenu setMenuVisible:YES animated:YES];

            break;
        default:
            break;
    }

}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    return (action == @selector(copy:) );
}

As I said, it works great building to the device and in the simulator, just not after Build & Archive.

  • 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-16T01:37:29+00:00Added an answer on June 16, 2026 at 1:37 am

    The NSAssert method was not called in the release build, because the -DNS_BLOCK_ASSERTIONS flag was enabled for release builds.

    In the above code, I fixed the issue by moving [self becomeFirstResponder] to its own line, assigning the return value to a BOOL, and then calling NSAssert on the BOOL.

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

Sidebar

Related Questions

I recently added Android's LVL copy protection to my app, and the results have
So I recently added Flurry analytics to my app and I added the user
I have recently added a new column (age) to a database table (user). I
I recently added CKEditor to my app and I would like to include my
I've got a legacy VB6 app that I recently added SetWindowPos to the application
I am working on an old VB6 app and have recently added the Siemens
I've recently just added Devise to my first Rails3 app, and I'm having a
I recently moved a django app from c:\Users\user\django-projects\foo\foobar to c:\Python25\Lib\site-packages\foo\foobar (which is on the
Until recently, our app did not specify a doctype. Then, to make the app
I'm using webapp with Google App Engine. I recently added a call to request.get('variable_name')

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.