Вот моя проблема. У меня есть массив пользователей, и я проверяю, есть ли номер телефона пользователя в адресной книге, я хочу показать пользователя в tableView.
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return users.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! UserCell
let user = users[indexPath.row]
let contact = searchForContactUsingPhoneNumber(phoneNumber: user.phoneNumber!)
if contact == true {
cell.textLabel?.text = user.name
cell.detailTextLabel?.text = user.phoneNumber
cell.backgroundColor = UIColor(r: 35, g: 35, b: 35)
cell.textLabel?.textColor = UIColor.white
cell.detailTextLabel?.textColor = UIColor.white
if let profileImageUrl = user.profileImageUrl {
cell.profileImageView.loadImageUsingCacheWithUrlString(profileImageUrl)
} else {
tableView.deleteRows(at: [indexPath], with: .automatic)
tableView.reloadData()
}
}
return cell
}
Вот что у меня есть. Это удаление строки пользователя, если номер телефона отсутствует в адресной книге, но вместо этого он оставляет белую строку.