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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:20:45+00:00 2026-05-20T13:20:45+00:00

I’m trying to activate a section of my code upon press (and hold) of

  • 0

I’m trying to activate a section of my code upon press (and hold) of a button only. When the button is released, I want my label to be invisible again. Is there a way to do this effectively? I have an IBAction (the button), and an IBOutlet (A textfield), with this code set for the action:

- (IBAction)toggleIt:(id)sender {
    if ([myDescription isHidden]) {
        [myDescription setHidden:NO];
    } else {
        [myDescription setHidden:YES];
    }
}

Any help? (In dummies terms)

Zach

  • 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-05-20T13:20:46+00:00Added an answer on May 20, 2026 at 1:20 pm

    I’m afraid there is no way of doing this in IB on the Mac as it would be possible on iOS:

    UIKit and AppKit — although similar in many regards — are two very different beasts. Where AppKit has a heritage that reaches back well into to the 1990s (maybe even late 1980s) which shows through in a few spots (I’m looking at you, NSCell), UIKit was designed with the experience of some 20 years on top of AppKit.

    And while you can easily tell a UIControl when its action is going to be invoked (and can have different actions for different events), NSControl merely allows you to specify one single action to be sent.

    If you don’t want to override -[NSButtonCell stopTracking:at:inView:mouseIsUp:] or -[NSButton mouseDown:] and -[NSButton mouseUp:], the easiest way you can achieve what you want should be to set the button to send its action continuously. This can be bone in IB (in the “Attributes” inspector under the “Control” category).

    The next thing would be to make your description layer-backed and rewrite your action method in a way like this:

    - (IBAction)toggleIt:(id)sender {
        CALayer *descriptionLayer = [myDescription layer];
        [descriptionLayer setHidden:NO]; // (ab-)use implicit animation
        [descriptionlayer performSelector:@selector(setHidden:) withObject:@"" afterDelay:.1];
    }
    

    How it works:

    The “hidden”-property of CALayer is animate-able and as such, changing it will cause an implicit animation. Since Objective C is just C, anything that is not 0x0 is interpreted as YES and that is where the third line strikes: The empty string clearly isn’t 0x0 so shortly after this action returned, the layer will be called to hide. But since CATransitions happen gradually and can be updated mid-course, this will only affect the visibility of the layer when the action is no longer triggered — i.e. the buton is no longer pressed.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.