我有带有 textfild 的自定义单元格。 对于某些单元格,我需要通过单击禁用 segue 并启用文本字段进行编辑。我试试看:
if indexPath.row<tests.count{
cell.themeTextField?.text = test.name
cell.themeTextField.enabled=false
}
else {
cell.accessoryType = UITableViewCellAccessoryType.None
cell.selectionStyle = UITableViewCellSelectionStyle.None;
cell.userInteractionEnabled = false;
}
Segue 被禁用,但我无法在 textField 中输入文本
最佳答案
尝试替代,
从 tableCell 中删除那个 segue 并从 UITableViewController
创建一个新的(将它从对象导航器而不是 Storyboard 中拖动)到下一个 Controller - 并给它一个名称(例如:DidSelectCellSegue
).
然后在 didSelectRowAtIndexPath:
委托(delegate)方法中,以编程方式和有条件地执行 segue。
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if conditionForPerformingSegueIsSatisfied {
self.performSegueWithIdentifier("DidSelectCellSegue", sender: self)
}
}
并将cellForRow
代码更改为
if indexPath.row<tests.count{
cell.themeTextField?.text = test.name
cell.themeTextField.enabled=false
}
else {
cell.accessoryType = UITableViewCellAccessoryType.None
cell.selectionStyle = UITableViewCellSelectionStyle.None;
cell.themeTextField.enabled = true;
}
关于ios - 如何通过单击 UITableViewController 中的自定义单元格来禁用 segue 而不禁用此单元格中的 textField 编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682976/