我已经搜索了一段时间,但我找不到问题的答案。我有一个UITableViewCell
的自定义UITextField
。
我使用cellForRowAtIndexPath
创建一个包含单元格的表格。在将用户带到UIView
的{{1}}中,用户指定他们希望拥有多少行。当用户前后移动时,UITableViewController
文字似乎丢失,并且未显示在UITextField
基本上,我无法获取用户输入要保存的文本。这是我的代码:
CustomeCell.m
UITableView
来自TableViewController.m
@implementation customCell
@synthesize aTextField;
-(void)layoutSubviews{
aTextField = [[UITextField alloc] initWithFrame:CGRectMake(7, 3, 65, self.contentView.bounds.size.height-6)];
[aTextField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[aTextField setAutocorrectionType:UITextAutocorrectionTypeNo];
[aTextField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[aTextField setBorderStyle:UITextBorderStyleRoundedRect];
aTextField.textAlignment = NSTextAlignmentCenter;
aTextField.keyboardType = UIKeyboardTypeNumberPad;
[self.aTextField addTarget:self action:@selector(aTextFieldEditing:) forControlEvents:UIControlEventEditingChanged];
[aTextField setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[aTextField setPlaceholder:@"begin"];
[self.contentView addSubview:aTextField];
}
-(void)aTextFieldEditing:(UITextField*)textField{
aTextField.text = textField.text;
}
@end
有什么建议吗?提前谢谢。