я создал 2 UITextField
с и UIButton
программным способом, когда я нажимаю UIButton
Я хочу, чтобы изменить текст выделенного UITextField
но не изменяя текст второго UITextField
выделенным один.Невозможно изменить текст UITextField
-(void)viewDidLoad
{
txtf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 586, 45)];
txtf.borderStyle = UITextBorderStyleNone;
txtf.backgroundColor = [UIColor clearColor];
txtf.font = [UIFont systemFontOfSize:17];
txtf.autocorrectionType = UITextAutocorrectionTypeNo;
txtf.keyboardType = UIKeyboardTypeDefault;
txtf.returnKeyType = UIReturnKeyDone;
txtf.textAlignment = NSTextAlignmentLeft;
txtf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[self.view addSubview:txtf];
txtf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 586, 345)];
txtf.borderStyle = UITextBorderStyleNone;
txtf.backgroundColor = [UIColor clearColor];
txtf.font = [UIFont systemFontOfSize:17];
txtf.autocorrectionType = UITextAutocorrectionTypeNo;
txtf.keyboardType = UIKeyboardTypeDefault;
txtf.returnKeyType = UIReturnKeyDone;
txtf.textAlignment = NSTextAlignmentLeft;
txtf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[self.view addSubview:txtf];
}
- (IBAction)change:(id)sender
{
txtf.text = @"the text was changed"
}
есть ли способ решить эту проблему?
Что делать вы подразумеваете под «выделенным текстовым полем»? У кого есть фокус? – Antonio
@ Антонио да, я имею в виду сосредоточенное текстовое поле – AFB