0
我使用的通知中心得到通知上的UITextField完成编辑后,这里是我的代码...问题与处理文本框完成编辑通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFieldChange:) name:UITextFieldTextDidEndEditingNotification object:nil];
和我的功能...
-(void)textFieldChange:(id)sender{
UITextField *my=(UITextField *)sender; // NOT WORKING
if([my.text length]==0){
UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"Please Fill This" message:@"This Field Can Not be Kept Empty!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil, nil];
[myAlert show];
}
}
这是什么问题? ,我觉得发件人没有在文本框中输入类型!
但如果我必须给对象作为参数,那么我必须为每个textfields使用多个通知,那么我将它保留为零,并尝试键入发件人的投射。 – BaSha
所以尝试使用第一个选项,我告诉过你,它将适用于任何数量的文本框我的朋友..-(BOOL)textFieldShouldEndEditing:(UITextField *)textField – NiravPatel
谢谢你,第一个解决方案的工作! – BaSha