Ios 如何通过单击UITableViewController中的自定义单元格禁用segue,而不在此单元格中禁用文本字段编辑
我有带textfild的自定义单元格。 对于某些单元格,我需要通过单击禁用segue并启用文本字段进行编辑。我尝试这样做:Ios 如何通过单击UITableViewController中的自定义单元格禁用segue,而不在此单元格中禁用文本字段编辑,ios,swift,Ios,Swift,我有带textfild的自定义单元格。 对于某些单元格,我需要通过单击禁用segue并启用文本字段进行编辑。我尝试这样做: if indexPath.row<tests.count{ cell.themeTextField?.text = test.name cell.themeTextField.enabled=false } else { cell.accessoryType = UITableViewCellAcce
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;
}
如果indexath.row尝试另一种方法
从tableCell中删除该序列,并从UITableViewController
(从对象导航器而不是情节提要中将其拖动)创建一个新的序列到下一个控制器-并为其命名(例如:DidSelectCellSegue
)
然后在didselectrowatinexpath:
delegate方法中,以编程方式和条件执行该步骤
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if conditionForPerformingSegueIsSatisfied {
self.performSegueWithIdentifier("DidSelectCellSegue", sender: self)
}
}
并将cellForRow
code更改为
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;
}
如果indexath.row尝试另一种方法
从tableCell中删除该序列,并从UITableViewController
(从对象导航器而不是情节提要中将其拖动)创建一个新的序列到下一个控制器-并为其命名(例如:DidSelectCellSegue
)
然后在didselectrowatinexpath:
delegate方法中,以编程方式和条件执行该步骤
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if conditionForPerformingSegueIsSatisfied {
self.performSegueWithIdentifier("DidSelectCellSegue", sender: self)
}
}
并将cellForRow
code更改为
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;
}
如果indexath.row尝试另一种方法
从tableCell中删除该序列,并从UITableViewController
(从对象导航器而不是情节提要中将其拖动)创建一个新的序列到下一个控制器-并为其命名(例如:DidSelectCellSegue
)
然后在didselectrowatinexpath:
delegate方法中,以编程方式和条件执行该步骤
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if conditionForPerformingSegueIsSatisfied {
self.performSegueWithIdentifier("DidSelectCellSegue", sender: self)
}
}
并将cellForRow
code更改为
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;
}
如果indexath.row尝试另一种方法
从tableCell中删除该序列,并从UITableViewController
(从对象导航器而不是情节提要中将其拖动)创建一个新的序列到下一个控制器-并为其命名(例如:DidSelectCellSegue
)
然后在didselectrowatinexpath:
delegate方法中,以编程方式和条件执行该步骤
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
if conditionForPerformingSegueIsSatisfied {
self.performSegueWithIdentifier("DidSelectCellSegue", sender: self)
}
}
并将cellForRow
code更改为
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;
}
if indexath.row在else中启用themeTextField
并进行检查。@Akhilrajtr在else中启用themeTextField
并进行检查没有帮助。@Akhilrajtr在else中启用themeTextField
并进行检查没有帮助。@Akhilrajtr没用