can*_*boy 5 iphone objective-c uitextfield ios
如果我有一系列表格单元格,每个表格单元格都有一个文本字段,我将如何使特定的文本字段成为第一个响应者?
// 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;
}
Run Code Online (Sandbox Code Playgroud)
我希望这可以帮助你......
| 归档时间: |
|
| 查看次数: |
6461 次 |
| 最近记录: |