How to make UITextView show spell suggestions on top rather than under the text
Hi,
I have an issue my UITextView showing spell suggestions under the typing text. But I would like it to be shown top of my typing text. Because when its showing down spell suggestions are clipped by the keyboard appearing.
Could some one kindly suggest me a way to get rid of this problem.
mm.. I didn't get it.. This is the issue I have in following screen shot. I want to show up suggestion without clipping to keyboard. Thanks for your kind reply. Still couldn't have any idea how to get it up.
Suggestion appearing down and clipping textfield
I think by translate he meant the geometrical term, like moving it up, down, left, or right (in your case, up)
if you can find a way to hide the red lines but still have the corrections show then you could make a copy of your uiTextView with white text (or whatever color is your background) so that the text wouldn't show up.. then only the red lines would be visible, now put the copy of the UITextView in black text (again, or whatever color) and move it all down 1 whole line so the red lines in the background are above the same words in the foreground.. but you will run into issues with editing is the problem..
__________________
APPS4LIFE
search for me in the app store.
Last edited by orange gold; 11-07-2010 at 01:30 AM.
import your own font with upside down text and then flip the UITextView upside down...
Code:
textView1.transform = CGAffineTransformMakeRotation(3.1415926535);//aka pi radians (upside down)
Then the font, or whatever they type will show up right side up and all of the lines will be on the top because it's really upside down, they will just never be able to know
**note you will have to change your alignment from right to left, also there might be issues with word ordering but that is easily fixable on your end.
__________________
APPS4LIFE
search for me in the app store.
Could really feel like very tricky solution to implement. But I wonder how iPhone Messages App UITextView (possibly) gets its spelling suggestions on top of typing text. May be something to make with positioning ?? or some clipping to bounds.. But hope some easier solution could be there..
By doing the search for the UIAutocorrectInlinePrompt in an overridden or swizzled layoutSubViews it is possible to alter the layout of the correction so that it appears above. You can do this without calling any private APIs by looking for the subs views of particular classes positioned in a way you'd expect them. This example works out which view is which, checks to see that the correction is not already above the text and moves the correction above, and draws it on the window so that it is not bounded by the UITextView itself. Obviously if apple change the underlying implementation then this will fail to move correction. Add this to your overriden or swizzled layoutSubViews implementation.
I was able to think about some easy way. Adding a @"\n" character always as first character.
My text view always have a new line character so user will be starting to type on second line. The typing text view is little bit adjusted to top. So suggestions are coming on top. Just to show the user i have some background text view that is disabled for input. If he deletes text he can only delete up to 1 character left, which is new line character..
Code:
- (void)viewDidLoad {
textView.text = @"\n";
}
...
.....
// I have a disabled text view which is placed under second line of editable // text view
- (void)textViewDidChange:(UITextView *)textView {
if (textView.text.length == 0) {
textView.text = @"\n";
textView.selectedRange = NSMakeRange(textView.text.length, 0);
}
}
In text view from second line onwards when you type suggestions coming up.