UIActivityIndicatorView is not display at the right time

Posted by Alexandre on Stack Overflow See other posts from Stack Overflow or by Alexandre
Published on 2012-11-09T10:58:49Z Indexed on 2012/11/09 10:59 UTC
Read the original article Hit count: 420

I'm making a form that allows the user to enter datas in my IOS application. This form allows the user to enter a lot of repetive datas. So, sometimes, the process takes time and I would like to display a UIActivityIndicatorView during this process.

Unfortunalty the spinner appears only one second or less at the end of the process, not at the beginning as expected.

There is some code :

- (void) manageSpinner{
    spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [spinner setCenter:CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0)]; // I do this becau I'm in landscape mode
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.tableView.bounds];
    UIImage *image = [UIImage imageNamed:@"dark_gradiant.jpg"];
    [imageView setImage:image];
    [imageView addSubview:spinner];
    [self.tableView addSubview:imageView];
    [spinner startAnimating];

//On click save by the user
- (IBAction)save:(id)sender{

    //Collect information from the form

    myObject.name = nameTF.text;


    if(informations OK[...]){        
        //Manage spinner
        [self manageSpinner];

        //Add : this is the long process
        for (int i=0; i<nbRepeatChooseByUser; i++) {
            [myObject register];

        //Call the delegate that will dismiss the form
        [self.delegate theSaveButtonOnTheAddMyObjectTVCWasTapped:self];

The spinner is called before the adding method but it seems to be set up after the process.

Thank you,


© Stack Overflow or respective owner

Related posts about ios

Related posts about uiactivityindicatorview