0

i have a uiswitch in each tableViewCell that initiates a network action. I want to superimpose a uiActivityInidicator over the switch until the server answers. I have seen this done with a uibarbutton.

I have added code to this previously working method that has a subclassed UISwitch, but no spinner is displayed.

any ideas?

- (IBAction)changeState:(id)sender {
    Plug *plug = [self.fetchedResultsController objectAtIndexPath:       ((NamedUISwitch*)sender).indexPath];
    if(((NamedUISwitch*)sender).on){
        plug.state = @"1";
    } else {
        plug.state = @"0";
    }


    NamedUISwitch *theSwitch=(NamedUISwitch*)sender;
    UIActivityIndicatorView *spinner=[[UIActivityIndicatorView    alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [spinner startAnimating];
    [theSwitch addSubview:spinner];
    // send message to server
 }
4

1 回答 1

1

As of iOS 5.x, UIActivityIndicator conforms to UIAppearance, and so it now has a color property which changes the color of the spinner.

于 2012-05-18T02:21:20.890 回答