我制作了一个包含 UITextField 和 UITableView 的应用程序。 如果用户在 UITextField 中输入一些文本,我想禁用 UITableView 的所有功能/按钮。因此,如果用户使用 UITextField,则无法在 UITableViewCell 上向左滑动(通常会出现删除按钮)。因此,用户只能在显示键盘时使用 UITextFiled。
我该怎么做?
最佳答案
使用文本框委托(delegate)方法
- (void)textFieldDidBeginEditing:(UITextField *)textField{
//check if(textfield==yourtextfield) if you have more than one textfields
tableView.userInteractionEnabled = NO;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
tableView.userInteractionEnabled = YES;
}
关于ios - 显示键盘时禁用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29416726/