uitextinput

How to get range of characters from a tapped word UITextview

坚强是说给别人听的谎言 提交于 2019-12-12 01:57:31
问题 I need to get the range of characters from a tapped word from a UITextView. I have set up a UITapGestureRecognizer on my instance of UITextView *tv . I currently have a solution that can tell me the word that was tapped, as described in this solution: Get word from tap in UITextView. I need the range of characters of the word that was tapped, not just the word itself, preferably available in a way where I can access the start and end values as integers. 回答1: The solution I have used is: int

UITextInput.characterRange(at:) is off by a few pixels

醉酒当歌 提交于 2019-12-11 15:13:00
问题 After adding a tap recognizer to my UITextView subclass, I'm attempting to get the character that is being tapped: var textRecognizer: UITapGestureRecognizer! required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) textContainer.lineFragmentPadding = 0 textContainerInset = .zero textRecognizer = UITapGestureRecognizer(target: self, action: #selector(textTapped)) textRecognizer.numberOfTapsRequired = 1 addGestureRecognizer(textRecognizer) } @objc func textTapped(recognizer:

Xcode: Creating a custom keyboard just for my own app

放肆的年华 提交于 2019-12-10 15:15:33
问题 I am developing a math application. So I need a specific keyboard. I just could take the decimal pad, but there is missing the positive/negative ("+/-") button. Now I want to program a custom keyboard or I would like to edit the decimal pad. What is more easy? If I would program my own custom keyboard, can I use the custom keyboard extension or do I have to create a view with a button for every number in a separate view? Because I need the keyboard on many different views: Is there a

Problems with <UITextinputDelegate> protocol implementation

孤街浪徒 提交于 2019-12-10 10:18:51
问题 What I am trying to implement is a UITextField that sees words as characters. Specifically, im trying to see the mathemathical expression sin( as one character for example. I thought to solve this problem by implementing my own UITextInputDelegate. However, the four required functions from this protocol never get called when I implement or adopt this protocol. I tried implementing it in the following ways: By subclassing a UITextField . @interface BIDUItextFieldDelegate : UITextField <

UITextView get the current line

大城市里の小女人 提交于 2019-12-09 06:07:45
问题 Is there a way (crazy hacks welcome) to get the current line as a string of a UITextView? This would include word wrapping, etc. For example, in this case: The method would return "stack overflow. Isn't it great? I" because that is the current line based on the cursor. It could also return "This is a test I made for" or "think so", based on the position of the cursor. I have tried working with both the UITextView methods and those of UITextInput protocol. EDIT: Here is the code I have

Animating UITextInput's textInputView

流过昼夜 提交于 2019-12-07 03:04:14
问题 UIKit text input components, such as UITextView and UITextField have a property inputView to add a custom keyboard. There are two questions I have relating to this. If the keyboard is currently visible and the property is set to a new input view, nothing happens. Resigning and regaining first responder status refreshes the input and displays the new view. Is this the best way to do it? If so it might answer my bigger question: Is it possible to animate the transition between two input views?

UITextInput: selectedTextRange vs. markedTextRange?

妖精的绣舞 提交于 2019-12-06 00:24:00
问题 Ok, so I know Apple's UITextInput protocol requires the two UITextRange properties selectedTextRange and markedTextRange and the documentation says that selectedTextRange is a subrange of markedTextRange which is an uncomfirmed text range by the user yatta yatta. That still doesn't make some things clear to me regarding how I ought to implement the two text ranges differently. Could someone visually explain to me the difference between selectedTextRange and markedTextRange ? I know that when

UITextInput setMarkedText:selectedRange not working? (Can't be!)

我怕爱的太早我们不能终老 提交于 2019-12-06 00:18:33
问题 I want to set the marked text programmatically and since iOS5 UITextView and UITextField conform to UITextInput this should be possible but for some reason I always get the markedText to be nil. :( What am I missing here? This is what I've tried without success: (While the textview is firstResponder) 1.- When the text view contains no text: text: "", selectedRange : {0,0}, markedText: nil. [_textView setMarkedText:@"月" selectedRange:NSMakeRange(0, 1)]; Result: text : "", selectedRange: {0,0},

Problems with <UITextinputDelegate> protocol implementation

核能气质少年 提交于 2019-12-05 21:13:43
What I am trying to implement is a UITextField that sees words as characters. Specifically, im trying to see the mathemathical expression sin( as one character for example. I thought to solve this problem by implementing my own UITextInputDelegate. However, the four required functions from this protocol never get called when I implement or adopt this protocol. I tried implementing it in the following ways: By subclassing a UITextField . @interface BIDUItextFieldDelegate : UITextField < UITextInputDelegate > By subclassing a NSObject. @interface BIDTextfieldInputDelegate : NSObject <

Animating UITextInput's textInputView

情到浓时终转凉″ 提交于 2019-12-05 07:53:14
UIKit text input components, such as UITextView and UITextField have a property inputView to add a custom keyboard. There are two questions I have relating to this. If the keyboard is currently visible and the property is set to a new input view, nothing happens. Resigning and regaining first responder status refreshes the input and displays the new view. Is this the best way to do it? If so it might answer my bigger question: Is it possible to animate the transition between two input views? From the UIResponder docs: Responder objects that require a custom view to gather input from the user