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

Alister

Stop crying with UITableView and UICollectionView.

В очередной раз перебирая crash логи большого проекта мы устали выгребать тысячи падей у таблиц и collectionView из-за потоков, неверных просчетов секций, индексов и давно всеми известной темы – проблемы с апдейтами у UICollectionView. Пул Read more...

ios

Automation in development

You can easily automate creating enum with property names, like mogenerator by using this service – http://s.oks.im/modelObjcEnumGenerator.workflow.zip Just select your property list, right click and select – Services -> modelObjcEnumGenerator. And than paste from clipboard. Thats Read more...

Useful

Xcode build script using

It’s not a secret, that Xcode can run BASH scripts on some events.   But, sometimes when you add your script to Xcode, you don’t think about future modification, git blame, and merge conflict. I Read more...