Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling AutoCorrect View Position on iPhone

Is there a way to control the position of the auto correct view that pops up while typing in a UITextField?

By default it appears to always appear below the text field. However in Apple's apps like SMS it sometimes appears above the text field.

For text fields aligned right above the keyboard the auto correct is blocked by the keyboard and not usable.

like image 927
Michael Brennan Avatar asked May 26 '09 15:05

Michael Brennan


People also ask

How do I manage autocorrect?

You can do this through the Settings app by going to Settings > System & updates > Languages and input > Keyboards > Gboard. For a faster method, you can reach the autocorrect area on Android devices by opening your keyboard and long-pressing on the comma key, then tapping the gear icon that appears.


1 Answers

The position of the auto correction prompt is determined by the firstRect... method of the UITextInput protocol. Unfortunately UITextField uses a private class as delegate for this protocol so you cannot subclass and override it.

You COULD however implement your own UITextField replacement by drawing the contents yourself (like with CoreText), implement your own selection and loupe handling and then you would be able to affect the position of the auto correction prompt. Though it's designed to always be below the edited text, so you would have to essentially lie on the firstRect ... method.

Long story short: it's too much hassle.

like image 113
Cocoanetics Avatar answered Oct 29 '22 16:10

Cocoanetics