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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:03:24+00:00 2026-06-12T01:03:24+00:00

I’m having a problem with the enabling/disabling of a UIButton, disabling the button works

  • 0

I’m having a problem with the enabling/disabling of a UIButton, disabling the button works fine if I don’t enable it again later in my code. When I do enable it later on it shows up as though it’s disabled (the opacity changes) yet when I press it the attached IBAction function is still called.

The code:

- (void)loadDataFromURL:(NSURL *)URL withLoadIndicator:(UIActivityIndicatorView *)loadIndicator errorName:(NSString *)name sender:(id)sender andCallback:(SEL)selector{

    // Start loading indicator, block button so we will have only one call at a time
    [loadIndicator startAnimating];

    if ([sender isKindOfClass:[UIButton class]]) {
        UIButton *button = sender;
        [button setEnabled:NO];
    }

    // Run the data load sequence
    self.dispatchQueue = dispatch_queue_create("com.companyname.settingsqueue", 0);

    dispatch_async(self.dispatchQueue, ^{
        // Downloading JSON and using CoreData to put it into the sqlite database here
    });

    // After loading is complete stop animating and re-enable the button
    dispatch_async(dispatchQueue, ^{
        [loadIndicator stopAnimating];
        if ([sender isKindOfClass:[UIButton class]]) {
            UIButton *button = sender;
            button.enabled = YES;
        }
    });
}

The strange thing is it works perfectly for the loadIndicator. The button I get from the sender parameter in the function does exist (it’s not null). When I remove button.enabled = YES; it stays disabled as it should. Is there a way to enable it again after my async code has executed without the button still being enabled during the async execution?

Thanks in advance for helping me.

  • 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-12T01:03:31+00:00Added an answer on June 12, 2026 at 1:03 am

    I found the answer to my problem after extensive searching. Because I wasn’t running all my UIView functions on the main thread the UI didn’t update even though my function finished. Therefor the button disabled for a really short time and then enabled again, even though my overlaying UIView and UIActivityIndicator were not yet removed from the screen.

    I hope this helps someone else with similar issues.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I've tracked down a weird MySQL problem to the two different ways I was
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am currently running into a problem where an element is coming back from

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.