Per UITextView
impostare textView.userInteractionEnabled = false
e se si dispone di UITextField
, impostare textField.userInteractionEnabled = false
.
Se si desidera che il textView o textField di essere modificabile dopo la cella con esso è sfruttato, fare qualcosa di simile:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let cell = tableView.cellForRowAtIndexPath(indexPath)! as UITableViewCell
// find first textField inside this cell and select it
for case let textField as UITextField in cell.subviews {
textField.userInteractionEnabled = true
textField.becomeFirstResponder()
return
}
// find first textView inside this cell and select it
for case let textView as UITextView in cell.subviews {
textView.userInteractionEnabled = true
textView.becomeFirstResponder()
return
}
}
quindi assicurarsi di disattivare l'interazione utente dopo aver terminato l'editing:
func textFieldDidEndEditing(textField: UITextField) {
textField.userInteractionEnabled = false
// rest of the function
}
func textViewDidEndEditing(textView: UITextView) {
textView.userInteractionEnabled = false
// rest of the function
}
non dimenticare di impostare il UITextFieldDelegate
e/o UITextViewDelegate
Spero che questo ha aiutato qualcuno :)
userInteractionEnabled = NO lavorato. Grazie mille. –
Una vista testo non ha una proprietà abilitata. –