adding settext validations for placeholder
Adding check for delegate to avoid crashes
This commit is contained in:
parent
1273321387
commit
a1effe87a4
@ -20,6 +20,7 @@
|
||||
-(void) didSetFont:(UIFont *) font;
|
||||
-(void) didSetContainerInset:(UIEdgeInsets)textContainerInset;
|
||||
-(void) didSetTextColor:(UIColor *)textColor;
|
||||
-(void) didSetText:(NSString *)text;
|
||||
|
||||
@end
|
||||
|
||||
@ -50,6 +51,11 @@
|
||||
[self.delegateForUIChange didSetTextColor:textColor];
|
||||
}
|
||||
|
||||
- (void)setText:(NSString *)text {
|
||||
[super setText:text];
|
||||
[self.delegateForUIChange didSetText:text];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@ -103,33 +109,61 @@
|
||||
// self.placeHolderLabel.textColor = textColor;
|
||||
}
|
||||
|
||||
- (void)didSetText:(NSString *)text {
|
||||
[self showOrHidePlaceholderForTextView:self.textView];
|
||||
}
|
||||
|
||||
#pragma Mark UITextView Delegate methods forwarding
|
||||
|
||||
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView {
|
||||
return [self.delegate textViewShouldBeginEditing:textView];
|
||||
if ([self.delegate respondsToSelector:@selector(textViewShouldBeginEditing:)]) {
|
||||
return [self.delegate textViewShouldBeginEditing:textView];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
-(void)textViewDidBeginEditing:(UITextView *)textView {
|
||||
[self.delegate textViewDidBeginEditing:textView];
|
||||
[self showOrHidePlaceholderForTextView:textView];
|
||||
[self showOrHidePlaceholderForTextView:textView];
|
||||
if ([self.delegate respondsToSelector:@selector(textViewDidBeginEditing:)]) {
|
||||
[self.delegate textViewDidBeginEditing:textView];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
|
||||
return [self.delegate textView:textView shouldChangeTextInRange:range replacementText:text];
|
||||
if ([self.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)]) {
|
||||
return [self.delegate textView:textView shouldChangeTextInRange:range replacementText:text];
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
-(void)textViewDidChange:(UITextView *)textView {
|
||||
[self.delegate textViewDidBeginEditing:textView];
|
||||
[self showOrHidePlaceholderForTextView:textView];
|
||||
if ([self.delegate respondsToSelector:@selector(textViewDidChange:)]) {
|
||||
[self.delegate textViewDidChange:textView];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)textViewShouldEndEditing:(UITextView *)textView {
|
||||
return [self.delegate textViewShouldEndEditing:textView];
|
||||
if ([self.delegate respondsToSelector:@selector(textViewShouldEndEditing:)]) {
|
||||
return [self.delegate textViewShouldEndEditing:textView];
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
-(void)textViewDidEndEditing:(UITextView *)textView {
|
||||
[self.delegate textViewDidEndEditing:textView];
|
||||
[self showOrHidePlaceholderForTextView:textView];
|
||||
if ([self.delegate respondsToSelector:@selector(textViewDidEndEditing:)]) {
|
||||
[self.delegate textViewDidEndEditing:textView];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void) showOrHidePlaceholderForTextView:(UITextView *) textView {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user