Commit 2811661f0f45231a6e8ff31b3ead037869f2df97
1 parent
d15b3000
提交0.0.15
Showing
2 changed files
with
25 additions
and
17 deletions
CNLiveOrganizationValidationModule.podspec
CNLiveOrganizationValidationModule/Classes/CNLiveOrganizationValidationModule/View/CNLiveBOrganizationContentCell.m
| ... | ... | @@ -184,16 +184,20 @@ |
| 184 | 184 | |
| 185 | 185 | #pragma mark - ***监听实现*** |
| 186 | 186 | - (void)cnLiveBTextFieldTextDidChange:(NSNotification *)notification{ |
| 187 | - CNLiveBOrganizationTextField *textField = (CNLiveBOrganizationTextField *)notification.object; | |
| 188 | - if (textField) { | |
| 189 | - if (textField.contentLengthMax == 0) { | |
| 190 | - textField.contentLengthMax = 100; | |
| 191 | - } | |
| 192 | - if (textField.text.length > textField.contentLengthMax) { | |
| 193 | - NSRange range = NSMakeRange(0, textField.contentLengthMax); | |
| 194 | - textField.text = [textField.text substringWithRange:range]; | |
| 187 | + if ([notification.object isKindOfClass:[CNLiveBOrganizationTextField class]]) { | |
| 188 | + CNLiveBOrganizationTextField *textField = (CNLiveBOrganizationTextField *)notification.object; | |
| 189 | + if (textField) { | |
| 190 | + if (textField.contentLengthMax == 0) { | |
| 191 | + textField.contentLengthMax = 100; | |
| 192 | + } | |
| 193 | + if (textField.text.length > textField.contentLengthMax) { | |
| 194 | + NSRange range = NSMakeRange(0, textField.contentLengthMax); | |
| 195 | + textField.text = [textField.text substringWithRange:range]; | |
| 196 | + } | |
| 195 | 197 | } |
| 198 | + | |
| 196 | 199 | } |
| 200 | + | |
| 197 | 201 | |
| 198 | 202 | } |
| 199 | 203 | |
| ... | ... | @@ -378,16 +382,20 @@ |
| 378 | 382 | |
| 379 | 383 | #pragma mark - ***监听实现*** |
| 380 | 384 | - (void)cnliveBTextViewTextChange:(NSNotification *)notification{ |
| 381 | - CNLiveBOrganizationTextView *textView = (CNLiveBOrganizationTextView *)notification.object; | |
| 382 | - if (textView) { | |
| 383 | - if (textView.contentLengthMax == 0) { | |
| 384 | - textView.contentLengthMax = 400; | |
| 385 | - } | |
| 386 | - if (textView.text.length > textView.contentLengthMax) { | |
| 387 | - NSRange range = NSMakeRange(0, textView.contentLengthMax); | |
| 388 | - textView.text = [textView.text substringWithRange:range]; | |
| 385 | + if ([notification.object isKindOfClass:[CNLiveBOrganizationTextView class]]) { | |
| 386 | + CNLiveBOrganizationTextView *textView = (CNLiveBOrganizationTextView *)notification.object; | |
| 387 | + if (textView) { | |
| 388 | + if (textView.contentLengthMax == 0) { | |
| 389 | + textView.contentLengthMax = 400; | |
| 390 | + } | |
| 391 | + if (textView.text.length > textView.contentLengthMax) { | |
| 392 | + NSRange range = NSMakeRange(0, textView.contentLengthMax); | |
| 393 | + textView.text = [textView.text substringWithRange:range]; | |
| 394 | + } | |
| 389 | 395 | } |
| 396 | + | |
| 390 | 397 | } |
| 398 | + | |
| 391 | 399 | |
| 392 | 400 | } |
| 393 | 401 | ... | ... |