2017-10-13 3 views
0

J'ai travaillé sur la fonctionnalité de tableview de sorte que lorsqu'une cellule tableview est sélectionnée, la tableview recharge et affiche une coche dans la ligne sélectionnée. La ligne sélectionnée n'était pas mise en surbrillance et ne permettait pas de sélectionner plusieurs lignes.iOS 11 Sélection de table

Avec iOS 11, il a cessé de fonctionner comme prévu. Je voudrais que la ligne sélectionnée affiche une coche. En outre, l'arrière-plan de la ligne sélectionnée ne doit pas être mis en surbrillance et ne pas autoriser la sélection de plusieurs lignes.

func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { 
    let clientCell = tableView.dequeueReusableCell(withIdentifier: "clientCell", for: indexPath) 
    clientCell.selectionStyle = .none 

    if selectedIdxPath == indexPath.row { 
     clientCell.accessoryType = UITableViewCellAccessoryType.checkmark 
    } else { 
     clientCell.accessoryType = UITableViewCellAccessoryType.none 
    } 
    return clientCell 
} 

func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) { 
    selectedIdxPath = indexPath.row 
    tableView.reloadData() 
} 

Répondre

1

S'il vous plaît vérifier vos méthodes de délégué:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let clientCell = tableView.dequeueReusableCell(withIdentifier: "clientCell", for: indexPath) 
    clientCell.selectionStyle = .none 

    if selectedIdxPath == indexPath.row { 
     clientCell.accessoryType = UITableViewCellAccessoryType.checkmark 
    } else { 
     clientCell.accessoryType = UITableViewCellAccessoryType.none 
    } 
    return clientCell 
} 

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
    selectedIdxPath = indexPath.row 
    tableView.reloadData() 
}