Ios 如果再次点击表视图中的单元格,UIAlertController将给出sigabrt错误
点击时,AlertController在表视图的每个单元格中都能正常工作。在警报中按“OK”后,当我再次单击之前单击的同一单元格时,会显示sigabrt错误。不知道在这里该做什么。代码如下:Ios 如果再次点击表视图中的单元格,UIAlertController将给出sigabrt错误,ios,swift,uialertcontroller,Ios,Swift,Uialertcontroller,点击时,AlertController在表视图的每个单元格中都能正常工作。在警报中按“OK”后,当我再次单击之前单击的同一单元格时,会显示sigabrt错误。不知道在这里该做什么。代码如下: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withId
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! JobsTableViewCell
cell.jobTitle.text = jobTitle[indexPath.row]
cell.jobDescription.text = jobDetail[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! JobsTableViewCell
cell.jobTitle.text = jobTitle[indexPath.row]
cell.jobDescription.text = jobDetail[indexPath.row]
displayMessage(titleAlert: jobTitle[indexPath.row], userMessage: jobDetail[indexPath.row])
}
您的didSelect应该如下所示
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
displayMessage(titleAlert: jobTitle[indexPath.row], userMessage: jobDetail[indexPath.row])
}
无需在didSelect中再次排队您的didSelect应该如下所示
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
displayMessage(titleAlert: jobTitle[indexPath.row], userMessage: jobDetail[indexPath.row])
}
无需在didSelect中再次出列此jobTitle全局变量来自何处?为什么它是一个全局变量?@Msencenb它是这个类的变量,并且在ViewDidLoad()中添加了值。这个jobTitle全局变量来自哪里?为什么它是一个全局变量?@Msencenb它是这个类的变量,并且在ViewDidLoad()中添加了值