uitextviewdelegate

limit number of characters user may enter into multiple UITextViews

丶灬走出姿态 提交于 2019-12-14 03:59:36
问题 In some sense this question has already been answered at Limit number of characters in uitextview. But my particular case is that I have more than one textview in the same ViewController. So I am not sure how to fix that problem. Say I only have two textViews. How might I handle these cases: they both have the same character limit? each has different character limit? say 300 and 400 respectively. Do I use IBAction ? If yes how? 回答1: So you need IBOutlet for both textviews @property (weak,

UIText view delegate issue

怎甘沉沦 提交于 2019-12-13 15:26:25
问题 I want to resign keyboard from UItextview. How to implement UItextView delegate method programmatically. 回答1: If u want that ur keyboard is resigned when click on return then u have to write, implement this method.... - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if([text isEqualToString:@"\n"]) { [textView resignFirstResponder]; return NO; } return YES; } Just make it copy and paste....:) 回答2: Make sure you declare support

UITextView delegate calling multiple times

会有一股神秘感。 提交于 2019-12-12 12:19:24
问题 I am using UITextView and implemented the delegate function var count = 0 func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { print(text) count += 1 print(count) return true } sample When i select the predictive text from the Keyboard, shouldChangeTextInRange delegate is calling twice. Why this delegate calling twice? Why this happening with predictive text alone 回答1: Please use this code. It will work fine and hope It will be

How to set the Textview move up animation based on keyboard in the custom UIView class

只愿长相守 提交于 2019-12-12 05:27:05
问题 I have Custom UIView class in one textview. Custom View class frame set only some one view controller. My thought is when text view delegate methods textviewdidbeginediting animation of textview based on the keyboard height not worked correctly. I am using following code static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3; static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2; static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.2; static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216; static const

UITextView dynamic height scrolling doesn't work when long text is pasted

天大地大妈咪最大 提交于 2019-12-11 19:34:04
问题 I've implemented changing the height of UITextView dynamically when height reaches a certain value by following this solution https://stackoverflow.com/a/38454252/12006517 This works fine however text view freezes when I paste a large chunk of text in it first time. After pasting large chunk of text it doesn't go to the end of text content and cursor disappears while text view freezes. I've to hit delete key and start entering then it starts to work fine. Subsequent paste of large chunk of

iOS toggle default keyboard from ABC mode to 123 mode via code?

落爺英雄遲暮 提交于 2019-12-10 10:38:59
问题 I can see how to set the keyboard's overall type via: self.myTextView.keyboardType = UIKeyboardTypeDefault; How can I toggle the default keyboard's mode from ABC to 123 and back again via code? Basically the moment the user taps the @ character (the @ symbol is available when they're in 123 mode) I want to switch their keyboard back to ABC mode. Any ideas? 回答1: You might be able to accomplish this in by using the UITextViewDelegate. It allows you to intercept the keys as they are pressed in

UITextView make application crash when becomeFirstResponder called

坚强是说给别人听的谎言 提交于 2019-12-10 10:25:22
问题 I have a UITextView in a UIView . When viewLoad, I had a UIPickerView within a UIAlertView with "OK" button. When I select any value from picker and click "OK" I required to make UITextView active . For that I have written [<myTextView> becomeFirstResponder]; delegate method of UITextView . As soon as this method execute it make textViewShouldBeginEditing delegate method to be invoked. This method executes correctly and I have return TRUE here, but after that the execution goes back to the

How to create a new line by tapping the return key in UITextView ios

╄→гoц情女王★ 提交于 2019-12-08 02:46:14
问题 I am newly to iPhone. I have added one UITextView using XIB in my application, now after tapping on done key it's simply resigning the keyboard. But, I want to create a new line by tapping it, means it should go to the next paragraph. Please help me to achieve my output. Here is my code : - (void)textViewDidEndEditing:(UITextView *)textView1 { if (![textView1 hasText]) { [textView1 addSubview:placeholderLabel]; } else{ NSLog(@"done button clicked!!"); } CGRect rect; if(screenBounds.size

Detect linebreak in UITextView

北战南征 提交于 2019-12-06 12:54:35
Is there a way to detect line breaks occurred by the user or when the textview automatically changes line. I am going to change the height of the textview depending on the number of lines. Any help appreciated. Francesco You can use the method proposed in this answer to find the occurrences of @"\n", the newline character. You can see if the string change using the textViewDidChange: protocol method ( apple doc here ). If you want the heigh, directly, look at this answer . I think it can help. You can get the number of rows which is actually what i wanted to do. numLines = textView.contentSize

How to create a new line by tapping the return key in UITextView ios

主宰稳场 提交于 2019-12-06 12:02:44
I am newly to iPhone. I have added one UITextView using XIB in my application, now after tapping on done key it's simply resigning the keyboard. But, I want to create a new line by tapping it, means it should go to the next paragraph. Please help me to achieve my output. Here is my code : - (void)textViewDidEndEditing:(UITextView *)textView1 { if (![textView1 hasText]) { [textView1 addSubview:placeholderLabel]; } else{ NSLog(@"done button clicked!!"); } CGRect rect; if(screenBounds.size.height == 568)//iPhone5 { rect = CGRectMake(5, 76, 310, 491); } else{ if(_kisiOS7){ rect = CGRectMake(5, 76,