我在IB中创建了一个带UITextField的UITableViewCell(以及相关的UITableViewCell子类,.m & .h)。这个UITextField被连接到UITableViewCell子类中的IBOutlet,并具有属性。在我的表视图控制器中,我使用以下代码使用此自定义单元格:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"textfieldTableCell"];
if (cell == nil) {
// Create a temporary UIViewController to instantiate the custom cell.
UIViewController *temporaryController = [[UIViewController alloc] initWithNibName:@"TextfieldTableCell" bundle:nil];
// Grab a pointer to the custom cell.
cell = (TextfieldTableCell *)temporaryController.view;
// Release the temporary UIViewController.
[temporaryController release];
}
return cell;
}
UITextField 显示正常,点击后键盘如预期弹出,但我该如何访问(获取 .text 属性)每行包含的 UITextField?同时,我该如何处理 UITextFields 的 'textFieldShouldReturn' 方法?