gpt4 book ai didi

iphone - 如何使表格单元格中的 UITextField 成为第一响应者?

转载 作者:可可西里 更新时间:2023-11-01 05:24:36 24 4
gpt4 key购买 nike

如果我有一系列表格单元格,每个单元格都有一个文本字段,我如何让特定的文本字段成为第一响应者?

最佳答案

// Customize the appearance of table view cells.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UITextField *textField = [[UitextField alloc] init];
// ...
textField.delegate = self;
textField.tag = indexPath.row;
[cell addSubView:textField];
}
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}

关于iphone - 如何使表格单元格中的 UITextField 成为第一响应者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7661271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com