Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Problema com a localização dos alunos.

Estou com um problema com a localização dos alunos no mapa,. Por algum motivo esta sempre retornado o mesmo aluno no mapa (não importa em quem eu clicar, sempre pega apenas o primeiro aluno).

Link Google Drive: https://drive.google.com/drive/folders/1o64RkEC00foMHCbu3pqoKhBFq9BBLdOI?usp=sharing

case .mapa:
                       let mapa = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "mapa") as! MapaViewController
                       mapa.aluno = alunoSelecionado
                       self.navigationController?.pushViewController(mapa , animated: true)
                    break
2 respostas
solução!

Oi Matheus, tudo bem?

Precisamos configurar a tag da view (que nada mais é do que o identificador) de acordo com o indexPath da TableView.

Ficaria assim:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let celula = tableView.dequeueReusableCell(withIdentifier: "celula-aluno", for: indexPath) as! HomeTableViewCell
        let longPress = UILongPressGestureRecognizer(target: self, action: #selector(abrirActionSheet(_:)))
        guard let aluno = gerenciadorDeResultados?.fetchedObjects![indexPath.row] else { return celula }
        celula.configuraCelula(aluno)
        celula.addGestureRecognizer(longPress)

        longPress.view?.tag = indexPath.row

        return celula
    }

Tenta aí, qualquer coisa me avisa...

Abs.

Funcionou certinho, muito obrigado.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software