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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:39:19+00:00 2026-06-14T20:39:19+00:00

How to stop UIActivityIndicatorView when uitextview loads current location using google api. here is

  • 0

How to stop UIActivityIndicatorView when uitextview loads current location using google api.

here is my code:

@implementation ViewController
@synthesize loctxt;

 - (void)viewDidLoad {

        loctxt=[[UITextView alloc]initWithFrame:CGRectMake(10, 50, 220, 30)];
        loctxt.backgroundColor=[UIColor whiteColor];
        loctxt.delegate=self;
        [self.view addSubview:loctxt];

        locbtn=[[UIButton alloc]initWithFrame:CGRectMake(240, 50, 40, 30)];
        [locbtn addTarget:self action:@selector(clickToGetLocation)forControlEvents:UIControlEventTouchUpInside];
        locbtn.backgroundColor=[UIColor grayColor];
        [locbtn setImage:[UIImage imageNamed:@"sst14.gif"] forState:UIControlStateNormal];
        [self.view addSubview:locbtn];

        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }

    - (void)clickToGetLocation {

        spinner = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0,100, 20, 20)];
        [spinner setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
        [self.view addSubview:spinner]; 

         **[spinner startAnimating];**


        AppDelegate *delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
        NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=csv",delegate.latitude, delegate.longitude];

        NSError* error;
        NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
        NSLog(@"%@",locationString);

        locationString = [locationString stringByReplacingOccurrencesOfString:@"\"" withString:@""];
        **self.loctxt.text=[locationString substringFromIndex:6];**
    //if i use code [spinner stopanimating]; here then the indicator does not appear    

}
  • 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-14T20:39:21+00:00Added an answer on June 14, 2026 at 8:39 pm

    The problem is that you attempt to start the spinner, load data from the Internet, and then stop the spinner all on the main thread and all within the same method. Doing synchronous networking on the main thread is BAD.

    You need to start the spinner, then perform the network access in the background. When this is complete, you then stop the spinner on the main thread.

    GCD is very good for this. Something like this:

    - (void)clickToGetLocation {
        spinner = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0,100, 20, 20)];
        [spinner setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
        [self.view addSubview:spinner]; 
        [spinner startAnimating];
    
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            AppDelegate *delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    
            NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=csv",delegate.latitude, delegate.longitude];
    
            NSError* error;
            NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
            NSLog(@"%@",locationString);
    
            locationString = [locationString stringByReplacingOccurrencesOfString:@"\"" withString:@""];
    
            dispatch_async(dispatch_get_main_queue(), ^{
                self.loctxt.text = [locationString substringFromIndex:6];
                [spinner stopAnimating];
            });
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i stop propagation for link? <script src=http://code.jquery.com/jquery.min.js></script> <script> $(function() { $(#g).click(function(event){ alert(Link
I'm trying to stop using the arrow keys in vim. But instead of setting
How to stop an animation so it won't produce Completed event. Here's simple example
How do I stop Google's popup message that shows up upon hovering over the
To stop the user from leaving my page, I'm using this javascript: window.onbeforeunload =
I launch 'net stop spooler' using CreateProcess from my C++ program. It fails and
We're using the stop-service cmdlet to kill a few services on our boxes. Most
How do you stop the designer from auto generating code that sets the value
I'm trying to stop my service from restarting itself by using the following: @Override
stop = [[UIButton alloc] style:UIButtonTypeCustom target:self identifier:stop action:@selector[webView stopLoading]]; when i am using 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.