Dans mon projet Xcode, je charge les articles dans un Array
et les affiche ensuite sur un UITableViewController
. Pendant que ces éléments se chargent, le UITableViewController
est vide et n'est pas esthétiquement plaisant, donc je veux mettre un indicateur d'activité dans le UITableViewController
pendant le chargement des données. J'ai copié mon code en bas. Comment l'implémenter? (j'ai entendu quelque chose appelé un gestionnaire d'achèvement pourrait faire l'affaire, mais je ne suis pas sûr de savoir comment l'utiliser)Indicateur d'activité pendant les charges de table
func loadAnimals() {
let animalQuery = PFQuery(className: "Animals")
animalQuery.whereKey("userID", equalTo: PFUser.current()?.objectId! ?? String()) //getting which user
animalQuery.limit = 10
animalQuery.findObjectsInBackground { (objects, error) in
if error == nil {
self.colorArray.removeAll(keepingCapacity: false)
self.animalNameArray.removeAll(keepingCapacity: false)
self.animalTypeArray.removeAll(keepingCapacity: false)
for object in objects! {
self.colorArray.append(object.value(forKey: "colorType") as! String) // add data to arrays
self.animalNameArray.append(object.value(forKey: "animalName") as! String) // add data to arrays
self.animalTypeArray.append(object.value(forKey: "animalType") as! String) // add data to arrays
}
self.tableView.reloadData()
} else {
print(error?.localizedDescription ?? String())
}
}
}
// met les couleurs en rangées
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! AnimalCell //connects to color cell
//Adds the animal information in the cells
cell.colorType.text = colorArray[indexPath.row]
cell.animalName.text = animalNameArray[indexPath.row]
cell.animalType.text = animalTypeArray[indexPath.row]
return cell
}
double possible de [Lieu indicateur d'activité sur uitable vue] (https://stackoverflow.com/questions/29311093/place-activity-indicator-over-uitable- voir) – MwcsMac