Курс 2 Урок 36. Не открывается Алерт контроллер при клике по первой ячейке


#1

Добрый день

Делаю все как в уроке, но при клике на cell номер 0, не открывается Алерт контроллер с выбором источника фотографии.
Открывается только после второго клика по любой другой cell

Ничего не понимаю


#2

На это сообщение поступили жалобы от участников сообщества, поэтому оно временно скрыто.


#3
override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
    if indexPath.row  == 0 {
        let alertController = UIAlertController(title: "Источник фото", message: nil, preferredStyle: .actionSheet)
        let cameraAction = UIAlertAction(title: "Камера", style: .default, handler: { (action) in
            self.chooseImagePickerAction(sourse: .camera)
        })
        let photoLibAction = UIAlertAction(title: "Фото", style: .default, handler: { (action) in
            self.chooseImagePickerAction(sourse: .photoLibrary)
        })
        let cancelAction = UIAlertAction(title: "Отмена", style: UIAlertActionStyle.cancel, handler: nil)
        
        alertController.addAction(cameraAction)
        alertController.addAction(photoLibAction)
        alertController.addAction(cancelAction)
        self.present(alertController, animated: true, completion: nil )
    }
    tableView.deselectRow(at: indexPath, animated: true)
}

func chooseImagePickerAction(sourse: UIImagePickerControllerSourceType) {
    if UIImagePickerController.isSourceTypeAvailable(sourse) {
        let imagePicker = UIImagePickerController()
        imagePicker.allowsEditing = true
        imagePicker.sourceType = sourse
        self.present(imagePicker, animated: true, completion: nil )
    }
    
}

#4

не понимаю чт оне так
глаза сломал

спасибо, за подсказку


#5

Скопировал содержимое и удалил didselectRow

Потом создал заново и вклеил содержимое.
все теперь работает сразу…
магия, блин


#6

У вас didDeselectRowAt был)


#7

Спасибо!!

Вот почему заработало
Думал глюк, а оказывается просто глаз замылился

Точно!