如何在 UITableview
中获取数据,而不是点击键盘 UITextfield
。在 UITableview
中,如何进行数据的多选。
编辑:-我有一个 UITextfield
。点击它时,tableview 应该会弹出其中的数据而不是键盘。 When a row of tableview is selected, then checkmark should appear and that data should be seen in UITextfield
.
最佳答案
回答你的第一个问题 -
使用此代码将隐藏您的键盘。
-(BOOL)textField:(UITextField *)textField shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if([text isEqualToString:@"\n"]) {
[textField resignFirstResponder];
return NO;
}
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[self.view endEditing:YES];
// load your tableView here.
// Everything must be custom.that is your table view is just like a popup.
}
回答你的第二个问题 -
现在当前的情况是您的表格 View 显示在屏幕上。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *selectedValue = [yourArray objectAtIndex:indexPath.row];
yourTextView.text = selectedValue;
yourTableView.hide = YES;
}
在选择任何行后,该值会显示在 yourTextView 中。但之后您必须隐藏该 tableView。试试这个。也许这会对你有所帮助。
关于ios - 点击 UITextField 在 UITableView 中显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20679376/