Привет, ребята, я хочу спросить, я хочу выбрать строку в разделе таблицы, когда я выбираю строку раздела, будет отображаться alertController. но это не показывает, у меня есть другой метод в разделе 0, и он работает, но почему это не работает в разделе, я хочу выбрать. Вы можете мне помочь?
func numberOfSections(in tableView: UITableView) -> Int {
return 5
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 0 {
let selectSchoolVC = SelectSchoolPopUpVC()
selectSchoolVC.modalPresentationStyle = .fullScreen
selectSchoolVC.modalTransitionStyle = .crossDissolve
present(selectSchoolVC, animated: true, completion: nil)
} else if indexPath.section == 1 {
} else if indexPath.section == 2 {
} else if indexPath.section == 3 {
}
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Log Out", style: .destructive, handler: { (_) in
ProfileServices.shared.signOutUser()
let signInVC = SigninViewController()
let navController = UINavigationController(rootViewController: signInVC)
self.present(navController, animated: true)
}))
tableView.deselectRow(at: indexPath, animated: true)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "selectId", for: indexPath) as! SelectSchoolCell
return cell
} else if indexPath.section == 1 {
return UITableViewCell()
} else if indexPath.section == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "BadgedCell", for: indexPath) as! BadgeCell
cell.accessoryType = .disclosureIndicator
let item = infoArray[indexPath.row]
cell.nameLbl.text = item["title"]
cell.badgeString = item["badge"] ?? ""
cell.badgeTextColor = .white
cell.badgeColor = .red
return cell
} else if indexPath.section == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "helpId", for: indexPath)
let helpsArray = helpArray[indexPath.row]
cell.textLabel?.text = helpsArray
cell.textLabel?.textColor = #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
cell.textLabel?.font = UIFont(name: "NunitoSans-SemiBold", size: 16)
cell.accessoryType = .disclosureIndicator
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "signOutId", for: indexPath)
return cell
}