Questions tagged [uitextposition]

A position in a text container—that is, an index into the backing string in a text-display view.

27 questions
160
votes
5 answers

Getting and Setting Cursor Position of UITextField and UITextView in Swift

I've been experimenting with UITextField and how to work with it's cursor position. I've found a number of relation Objective-C answers, as in Getting the cursor position of UITextField in ios Control cursor position in UITextField UITextField get…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
52
votes
7 answers

Control cursor position in UITextField

I have a UITextField that I'm forcing formatting on by modifying the text inside the change notification handler. This works great (once I solved the reentrancy issues) but leaves me with one more nagging problem. If the user moves the cursor…
Jeremy
  • 849
  • 1
  • 7
  • 11
16
votes
2 answers

UITextPosition in UITextField

Is there any way for me to get at a UITextField's current caret position through the text field's UITextRange object? Is the UITextRange returned by UITextField even of any use? The public interface for UITextPosition does not have any visible…
futureelite7
  • 11,462
  • 10
  • 53
  • 87
13
votes
2 answers

UITextPosition to Int

I have a UISearchBar on which I am trying to set a cursor position. I am using UITectField delegates as I couldn't find anything direct for UISearchBar. Below is the code I am using: UITextField *textField = [searchBar valueForKey:…
tech_human
  • 6,592
  • 16
  • 65
  • 107
11
votes
4 answers

Vertically align text to the bottom of the box?

I made box and I set line-height, the text is automatically vertically center. Is there a way or any kind of trick to set the text on the bottom of the box? div { width: 100px; height: 100px; background: #eee; color: #333; …
phoxd
  • 1,546
  • 3
  • 12
  • 26
9
votes
2 answers

Objective C how to get the numeric value of a UITextPosition

I need to get the numeric value of the start and end of a UIText range. So far I can only print out the description as a string. From looking at the selectedTextRange, I take it that it is maybe a struct? How do I get an element of a…
OWolf
  • 5,012
  • 15
  • 58
  • 93
6
votes
1 answer

UITextView caretRectForPosition wrong value for last character after press delete key

I have a method for text changed in my web view to detect the visible rect for the current caret position. UITextPosition *endPos = self.selectedTextRange.end; CGRect rect = [self caretRectForPosition:endPos]; [self scrollRectToVisible:rect…
user1620350
2
votes
0 answers

CGRect of firstRectForRange method in UITextView returns wrong frame position in iOS 9

Running the below code in iPod 5 / iPad with iOS 8 and iOS 9 gives the below output CGRect textViewFrame; if(IS_IPHONE_5) textViewFrame = CGRectMake(0.0f, 64.0f, 320.0f, 390.0f); else textViewFrame = CGRectMake(0.0f, 64.0f, 320.0f,…
Kenshin
  • 1,030
  • 2
  • 12
  • 41
2
votes
1 answer

Building a CGPath around sentences in UITextView is incredibly slow at -positionFromPosition:

I'm doing some text analysis and have run into an annoying performance bump that I can't seem to find how to optimize. I start with the text from a UITextView and split the text into an array of sentences, splitting on characters in ".?!". Then I…
rnystrom
  • 1,906
  • 2
  • 21
  • 47
1
vote
0 answers

UITextPosition not working correctly in iOS 13.6 and above

I am working with UITextField with an existing text in it. I want to cursor appear at the beginning of the text when I focus on UITextField. Everything worked fine before I changed the version of iOS to 13.6 I want it to be like this: (iOS13.1) But…
1
vote
2 answers

How can I get the current selected line number inside UITextView?

I am using the below written method for getting the current selected line number of textView having attributed text. It works fine if last line is not blank. If last line goes blank this method is not giving a proper line number. Method : -…
1
vote
1 answer

Strange behavior when using setSelectedTextRange: on iOS 6

I'm seeing some very strange behavior with a UITextField. I have a custom keyboard implemented, and it works great on iOS 7+. However, on iOS 6, when the following line is called (after doing a "backspace"), the text field's cursor vanishes, it…
rebello95
  • 8,486
  • 5
  • 44
  • 65
1
vote
0 answers

Better way to get line ranges in a UITextView

Right now, I am able to get the text ranges of each line in a UITextView containing n lines by using cycling through the tokenizer with paragraph granularity. Unfortunately, that means my search algorithm for the m-th line in the text is of order n.…
rolling_codes
  • 15,174
  • 22
  • 76
  • 112
1
vote
6 answers

Android Button text positioning

How can I make the text appear NEXT to a button, instead of being ON the button? Here is a screenshot of what i need: You can see the text on the first button. It is written ON the button, and I couldn't move it from it (aside from changing the…
SteBra
  • 4,188
  • 6
  • 37
  • 68
1
vote
0 answers

how to align text to top of a text view dynamically

I have hit a problem when trying to align my text to the top of a text view dynamically. I have a method that creates textviews dynamically. I have set the gravity of the text view to Gravity.TOP. Which a believe should place the text at the very…
Paul Ledger
  • 1,125
  • 4
  • 21
  • 46
1
2