在我的Xcode项目我加载项为Array
,然后提出它在UITableViewController
。虽然这些项目加载UITableViewController
是空的,而不是美观,所以我希望把在UITableViewController
一个活动的指标,而它的加载数据。我在底部复制了我的代码。 如何实现这一点?(听说一种叫完成处理可能可能做的伎俩,但我不知道如何使用它)活动指示灯虽然泰伯维负荷
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())
}
}
}
//放置颜色行
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
}
[在uitable视图广场活动的指标(可能的重复https://stackoverflow.com/questions/29311093/place-activity-indicator-over-uitable-视图) – MwcsMac