【发布时间】:2016-05-30 12:44:53
【问题描述】:
我已经将 UITextField 的连接导出并编写了这段代码
-(void)viewDidLoad
{
[txtName addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}
-(void)textFieldDidChange :(UITextField *)theTextField{
NSLog(@"Text changed");
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if(textField==txtName)
{
[self.view endEditing:YES];
[self performSelector:@selector(ShowNames) withObject:nil afterDelay:0.1];
return NO;
}
return YES;
}
但是-(void)textFieldDidChange :(UITextField *)theTextField{ 没有被解雇
不明白我哪里错了
任何帮助将不胜感激
【问题讨论】:
-
请使用 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
-
@Honey,我在下面发布了答案,但是您在
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField中的 IF 语句返回了错误的值。将您的return NO与return YES交换,反之亦然。请参阅下面的整个方法的答案。 -
@Honey,运气好吗?我在下面的回答有帮助吗?
标签: ios iphone xcode ipad uitextfield