0

It seems like with a few apps that I've made and launched to my IPhone, I have to hold down on a table view cell to before any functionally I programmed happens. Can anyone tell me why, and how to fix it?

here is an example

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let message = messages[indexPath.row]
    let chatPartnerId: String?
    if message.fromId == FIRAuth.auth()?.currentUser?.uid{
        chatPartnerId = message.toId
    }else{
        chatPartnerId = message.fromId
    }

    let ref = FIRDatabase.database().reference().child("users").child(chatPartnerId!)
    ref.observeSingleEvent(of: .value, with: { (snapshot) in
        guard let dictionary = snapshot.value as? [String:AnyObject] else{
            return
        }
        let user = User()
        user.uid = chatPartnerId
        user.setValuesForKeys(dictionary)
        chosenUser = user
        self.performSegue(withIdentifier: "chatLog1", sender: nil)
    })



}
1
  • Can you give an example of the code that triggers one of these actions and where you're executing it? Jun 6, 2017 at 19:54

1 Answer 1

2

Instead of using the didSelectRowAt:indexPath method you could use the didHighlightRowAt:indexPath method like this:

   func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) {
        self.performSegue(withIdentifier: "chatLog1", sender: nil)
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.