사용 textFieldDidEndEditing 위임하는 방법.
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if([textField.text stringByReplacingOccurrencesOfString:@" "
withString:@""].length >0)
NSLog(@"Text Field Is Empty");
//or perform selector textFieldIsEmpty
}
추가통지 관찰자 UITextFieldTextDidChangeNotification 이름 :
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textFieldChanged:)
name:UITextFieldTextDidChangeNotification
object:self.yourTextField];
선택은 다음과 같이 될 것입니다 :
-(void)textFieldChanged:(NSNotification*)notification
{
UITextField *txt = (UITextField *)[notification object];
if([txt.text stringByReplacingOccurrencesOfString:@" "
withString:@""].length >0)
NSLog(@"Text Field Is Empty");
}
편집 : 레모 필요하지 않은 경우 알림을했습니다 :
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
안녕하세요, 감사합니다. 저는 텍스트보기 용으로 사물을 사용했는데 다시 감사드립니다. :) –
하지만 Repo가 충분하지 않기 때문에 충분한 레포를 얻을 수있을 것입니다. –
오, 저기 있어요 :) –