【发布时间】:2014-01-30 18:41:42
【问题描述】:
这是我的问题。我创建了一个 UITextField。
.h 文件:
@property (strong, nonatomic) UITextField *emailTextField;
.m 文件:
- (void)viewDidLoad
{
[super viewDidLoad];
self.emailTextField.delegate=self;
[self setTextFields:120 :@" email" :self.emailTextField];
}
-(void)setTextFields:(float)ycoord :(NSString *)text :(UITextField *)textField
{
CGRect frame = CGRectMake(60, ycoord, 180, 30);
textField = [[UITextField alloc]initWithFrame:frame];
textField.backgroundColor = [UIColor whiteColor];
textField.placeholder = text;
textField.font = [UIFont fontWithName:@"Baskerville" size:15];
textField.allowsEditingTextAttributes=YES;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
CALayer *lay = [textField layer];
[lay setCornerRadius:5.0f];
[self.view addSubview:textField];
}
目的是保存用户在 TextField 中输入的文本。我尝试了委托方法
-(void)textFieldDidEndEditing:(UITextField *)textField
但是没有调用该方法(我放了一个 NSLog 来检查)。有人可以帮忙吗?
【问题讨论】:
标签: ios objective-c text delegates uitextfield