Today I stuck with some interesting UITextField behaviour. So when you call:

And your current in this moment not visible, for example you don’t use scrolling in textView and text hidden by parent frame, you can get Infinite origin for cursorRect. It seems to be not so valid, as usually inline rect and values return in case of error.

Was very strange to receive in this case.

So I was used to update textView’s frame before calling caretRectForPosition:
Also if your caret is not visible you can get some strange origin – ex. {0, -800}, when your textView content height in this moment about {320, 90}.

Categories: iosUseful

Oksana Kovalchuk

Passionate IOS Developer

Related Posts

ios

Asset catalog system file names

Sometimes IOS become not so obvious and not clear. The same happens to me, when I try to load default splash screen. [crayon-58fe6622a7b39430958369/] Example for icons: [crayon-58fe6622a7b41121407238/] Related

Useful

Xcode Project Structure Example

Okay, this subject is very “intimate” for every developer, but I hope, this article will help somebody in his way to perfect organization of project structure. So lets start. Related

Snippet

Git cloning with sub-modules

For cloning  git repo with submodules, use this command: [crayon-58fe6622a7c67795543059/] For already cloned repos, for clone submodules use next command in repo root: [crayon-58fe6622a7c6d848138207/] And that’s all, Folks. Related