Using a prototype cell and custom UITableViewCell with a UISwitch and UIActivityIndicator. Flipping the switch causes an NSURL Post request and disables the switch. This is working fine.
Now, I’d like to connect up the Activity Indicator to have it spin during while the network request is working.
Added this in the subclassed UITableViewCell .h/.m
@property (nonatomic, weak) IBOutlet UIActivityIndicatorView *activity;
@synthesize activity;
Then in the UITableViewController, receive the switch change with:
- (IBAction)changeSwitch:(id)sender
{
UISwitch *mySwitch = (UISwitch *)sender;
[sender setEnabled:NO];
// turn on activity indicator (**Edited next 2 lines**)
UIActivityIndicatorView *av = (UIActivityIndicatorView*) [[self view] viewWithTag:2101];
[av setHidden:YES];
// create a datamanager to send the request
...
}
I’ve looked at tags, connections and considered calling a method of the TableViewCell to start/stop the indicator, but can’t find the answer.
How can the action of the switch connect to start the activity indicator?
Solved the problem of connecting to these prototype cell objects, by first giving them a tag number in the storyboard attributes inspector for the activity indicator & switch, and later accessing their properties from within the UITableViewController (subclass) using: