O. Boujaouane O. Boujaouane - 1 year ago 86
Swift Question

How to start animation of UIActivityIndicatorin in tableViewCell with Swift?

hope you are well.

I am trying to activate an UIActivityIndicator on specific cell of my tableview. I want to hide labels, images, buttons and show other elements instead of. One of these elements is an UIActivityIndicator which appears but doesn't animate :(

Here the code used :

func showProgressViewInCell(path: NSIndexPath) {
let cell = self.toursUITableView.cellForRowAtIndexPath(path) as! ToursTableViewCell;

// stop userInteraction
cell.userInteractionEnabled = false;

// hide elements
cell.downloadTourButton.hidden = true;
cell.descriptionLabel.hidden = true;
cell.typeOfTourLabel.hidden = true;
cell.typeOfTourImage.hidden = true;
cell.distanceOfTourLabel.hidden = true;
cell.distanceOfTourImage.hidden = true;
cell.durationOfTourLabel.hidden = true;
cell.durationOftourImage.hidden = true;
// show progressbar, percent, activityIndicator and updateLabel
cell.percentLabel.hidden = false;
cell.downloadTourProgressView.hidden = false;
cell.updateLabelProgressBar.hidden = false;
// downloadInProgressActivityIndicator uses option hides when stopped
cell.downloadInProgressActivityIndicator.hidden = false;

// reload data of tableview

Here the configuration on InterfaceBuilder of my UIActivityIndicator :

configuration of UIActivityIndicatorView on Interface Builder

This didn't worked for me : http://stackoverflow.com/a/29494991/6188918

In advance thank you for help.

Answer Source

Some time ago I made an app which displayed activity indicator inside a cell. I did it by calling startAnimating() inside of cellForRowAtIndexPath method of data source. Try this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download