Closed emresancaktar closed 4 years ago
In CLTextSettingsView.m change the following method to something like:
- (void)textViewDidChange:(UITextView*)textView
{
NSRange selection = textView.selectedRange;
if (selection.length == 0 && selection.location == 0) { // KKR 20191130 fix for adding text and then deleting all text
[textView scrollRangeToVisible:textView.selectedRange];
if([self.delegate respondsToSelector:@selector(textSettingView:didChangeText:)]){
[self.delegate textSettingView:self didChangeText:NSLocalizedString(@"Text", nil)];
}
return;
}
else if(selection.location+selection.length == textView.text.length && [textView.text characterAtIndex:textView.text.length-1] == '\n') {
[textView layoutSubviews];
[textView scrollRectToVisible:CGRectMake(0, textView.contentSize.height - 1, 1, 1) animated:YES];
}
else {
[textView scrollRangeToVisible:textView.selectedRange];
}
if([self.delegate respondsToSelector:@selector(textSettingView:didChangeText:)]){
[self.delegate textSettingView:self didChangeText:textView.text];
}
}
In CLTextSettingsView.m change the following method to something like:
- (void)textViewDidChange:(UITextView*)textView { NSRange selection = textView.selectedRange; if (selection.length == 0 && selection.location == 0) { // KKR 20191130 fix for adding text and then deleting all text [textView scrollRangeToVisible:textView.selectedRange]; if([self.delegate respondsToSelector:@selector(textSettingView:didChangeText:)]){ [self.delegate textSettingView:self didChangeText:NSLocalizedString(@"Text", nil)]; } return; } else if(selection.location+selection.length == textView.text.length && [textView.text characterAtIndex:textView.text.length-1] == '\n') { [textView layoutSubviews]; [textView scrollRectToVisible:CGRectMake(0, textView.contentSize.height - 1, 1, 1) animated:YES]; } else { [textView scrollRangeToVisible:textView.selectedRange]; } if([self.delegate respondsToSelector:@selector(textSettingView:didChangeText:)]){ [self.delegate textSettingView:self didChangeText:textView.text]; } }
Thank you bro,
It’s working great now.
Hey,
There is a bug on CLTextTool.
There is the error log;
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString characterAtIndex:]: Range or index out of bounds' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23ce1a71 _CFThrowFormattedException + 194 3 CoreFoundation 0x00007fff23ce1aa9 -[__NSCFString characterAtIndex:].cold.1 + 41 4 CoreFoundation 0x00007fff23b827bf -[__NSCFString characterAtIndex:] + 95 5 CLImageEditor 0x000000010d670b77 -[CLTextSettingView textViewDidChange:] + 311 6 UIKitCore 0x00007fff47b8b8c1 -[UITextView textInputDidChange:] + 121 7 UIKitCore 0x00007fff47b63b31 -[UITextInputController _sendDelegateChangeNotificationsForText:selection:] + 104 8 UIKitCore 0x00007fff47b66414 -[UITextInputController _insertText:fromKeyboard:] + 765 9 UIKitCore 0x00007fff47b67b88 -[UITextInputController deleteBackward] + 194 10 UIKitCore 0x00007fff47b87947 -[UITextView deleteBackward] + 37 11 UIKitCore 0x00007fff47666985 -[UIKeyboardImpl deleteBackwardAndNotify:] + 330 12 UIKitCore 0x00007fff47660a90 -[UIKeyboardImpl _performKeyboardOutput:shouldCheckDelegate:] + 666 13 UIKitCore 0x00007fff4765f84d __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2 + 372 14 UIKitCore 0x00007fff4768ee0d -[UIKeyboardTaskEntry execute:] + 147 15 UIKitCore 0x00007fff4768d923 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 310 16 Foundation 0x00007fff25761c40 __NSThreadPerformPerform + 259 17 CoreFoundation 0x00007fff23bb2221 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 18 CoreFoundation 0x00007fff23bb214c __CFRunLoopDoSource0 + 76 19 CoreFoundation 0x00007fff23bb1924 __CFRunLoopDoSources0 + 180 20 CoreFoundation 0x00007fff23bac62f __CFRunLoopRun + 1263 21 CoreFoundation 0x00007fff23babe16 CFRunLoopRunSpecific + 438 22 GraphicsServices 0x00007fff38438bb0 GSEventRunModal + 65 23 UIKitCore 0x00007fff4784fb48 UIApplicationMain + 1621 24 Photic 0x000000010cc673eb main + 75 25 libdyld.dylib 0x00007fff51a1dc25 start + 1 26 ??? 0x0000000000000002 0x0 + 2 ) libc++abi.dylib: terminating with uncaught exception of type NSException