【发布时间】:2015-04-01 14:39:26
【问题描述】:
我正在使用情节提要开发应用程序。 UITableViewCell (MoneyEntryTableViewCell) 有一个自定义类,其中包含 UITextField。
问题:
当我在键盘上按上一个/下一个 (<>) 时,我想将焦点移到其他单元格中添加的其他文本字段。
在.h文件中
@interface MoneyEntryTableViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *lblMemName;
@property (strong, nonatomic) IBOutlet UITextField *textAmount;
@property (strong, nonatomic) IBOutlet UILabel *lblmemId; // Hidden
@end
在 .m 文件中
@implementation MoneyEntryTableViewCell
@synthesize lblMemName,textAmount;
- (void)awakeFromNib {
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end
在 Controller 中,这是我的 cellForRowAtIndexPath 函数...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MoneyEntryTableViewCell *cell = (MoneyEntryTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"UserAmountCell"];
if (!cell)
{
cell = [[MoneyEntryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UserAmountCell"] ;
}
cell.selectionStyle =UITableViewCellSelectionStyleNone;
UILabel *lblname = (UILabel *) [cell lblMemName];
lblname.tag =100;
lblname.text = [[self.MembersList objectAtIndex:indexPath.row] objectAtIndex:0];
UILabel *lblId = (UILabel *) [cell lblmemId];
lblId.tag =101;
lblId.text = [[self.MembersList objectAtIndex:indexPath.row] objectAtIndex:1];
UITextField *txtfield = (UITextField *)[cell textAmount];
txtfield.tag = 200 + indexPath.row;
txtfield.placeholder = @"0.00";
txtfield.delegate = self;
[txtfield addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
txtfield.inputAccessoryView = keyboardDoneButtonView;
return cell;
}
【问题讨论】:
标签: ios uitableview uitextfield first-responder