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

  • Home
  • SEARCH
  • 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 6019045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:21:49+00:00 2026-05-23T03:21:49+00:00

I have a refresh button on my navigationbar buttonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonItemClicked)];

  • 0

I have a refresh button on my navigationbar

buttonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonItemClicked)];
    self.navigationItem.rightBarButtonItem = buttonItem;
-(void)buttonItemClicked{
    NSLog(@"buttonItemclicked");
    myView.labelName.text = nil;
    myView.otherLabelName.text = nil;
    [spinner startAnimating]
    [spinnerView setHidden:NO];
    [self requestAPI];
    [spinner stopAnimating];
    [spinnerView setHidden:YES];
  }

If I go in and out of the view, it works fine. But when I call the same methods in buttonItemClicked, it doesn´t work. I also tried calling the view methods inside my action method, but that doesn´t work either.

What I´m trying to do is set my labels to nil, add my UIActivityIndicatorView and remove it after the labels are set again.

I have already tried [self.view setNeedsDisplay];

The refresh it self works, but the animations doesn´t work.

Any suggestions?

  • 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-23T03:21:50+00:00Added an answer on May 23, 2026 at 3:21 am

    The animation is not working because you call startAnimating and stopAnimating (and setHidden) in the same method.
    The render start at the end of the method call.
    You need to set

    [spinner stopAnimating];
    [spinnerView setHidden:YES];
    

    in requestAPI.

    Edit:

    Using Grand Central Dispatch. Like:

    - (void)buttonItemClicked {
      myView.labelName.text = nil;
      myView.otherLabelName.text = nil;
      [spinner startAnimating]
      [spinnerView setHidden:NO];
      [self requestAPI];
    }
    
    - (void)requestAPI {
      dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSURL *url = [NSURL URLWithString:@"http://example.com"];
        NSData *data = [NSData dataWithContentsOfURL:url];
        NSString *stringResult = [[NSString alloc] initWithData:data
                                                       encoding:NSUTF8StringEncoding];
        dispatch_async(dispatch_get_main_queue(), ^{
          [spinner stopAnimating];
          [spinnerView setHidden:YES];
    
          myView.labelName.text = stringResult;
        });
    
      });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a refresh UIBarButtonItem to my navigation bar on my iPhone app.
I have a refresh button on my iphone screen that refreshes a table in
I have a refresh button in the toolbar that regenerates an NSArray and attempts
I have a Refresh button on my page that will perform an asp.net mvc
I am using SQLITE database in my iPhone app. I have a refresh button
simple question maybe but can't find solution. I have button for refresh/update some contents
I have a system that uses a meta refresh to a logout page, which
I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET
I have a page where I would like it to remain static after refresh
in my data layer class I have created a function to manually refresh the

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.