Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-06-2010, 03:39 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
tharindufit is on a distinguished road
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Question 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.

Thank you and Kind Regards,

Tharindu.
tharindufit is offline   Reply With Quote
Old 11-06-2010, 04:17 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

i think that you can't easily do it, maybe the right path is to translate your uitextview, so that can be seen the red line
__________________
dany_dev is offline   Reply With Quote
Old 11-07-2010, 01:16 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
tharindufit is on a distinguished road
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Default

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


Tharindu.

tharindufit is offline   Reply With Quote
Old 11-07-2010, 01:27 AM   #4 (permalink)
Gold Orange
 
orange gold's Avatar
 
Join Date: Sep 2008
Posts: 686
orange gold is an unknown quantity at this point
Default

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.
orange gold is offline   Reply With Quote
Old 11-07-2010, 01:30 AM   #5 (permalink)
Gold Orange
 
orange gold's Avatar
 
Join Date: Sep 2008
Posts: 686
orange gold is an unknown quantity at this point
Default

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.
orange gold is offline   Reply With Quote
Old 11-07-2010, 03:26 AM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
tharindufit is on a distinguished road
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Default

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..

Thanks a Lot,

Tharindu.
tharindufit is offline   Reply With Quote
Old 11-07-2010, 02:25 PM   #7 (permalink)
Gold Orange
 
orange gold's Avatar
 
Join Date: Sep 2008
Posts: 686
orange gold is an unknown quantity at this point
Default

Copy and Pasted from another website:

"

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.

Code:
- (void) moveSpellingCorrection {
 for (UIView *view in self.subviews)
 {
  if ([[[view class] description] isEqualToString:@"UIAutocorrectInlinePrompt"])
  {
   UIView *correctionShadowView = nil; // [view correctionShadowView];

   for (UIView *subview in view.subviews)
   {
    if ([[[subview class] description] isEqualToString:@"UIAutocorrectShadowView"])
    {
     correctionShadowView = subview;
     break;
    }
   }

   if (correctionShadowView)
   {
    UIView *typedTextView = nil; //[view typedTextView];
    UIView *correctionView = nil; //[view correctionView];

    for (UIView *subview in view.subviews)
    {
     if ([[[subview class] description] isEqualToString:@"UIAutocorrectTextView"])
     {
      if (CGRectContainsRect(correctionShadowView.frame,subview.frame))
      {
       correctionView = subview;
      }
      else
      { 
       typedTextView = subview;
      }
     }

    }
    if (correctionView && typedTextView)
    {

     CGRect textRect = [typedTextView frame];
     CGRect correctionRect = [correctionView frame];
     if (textRect.origin.y < correctionRect.origin.y)
     {
      CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0,-50.0);
      [correctionView setTransform: moveUp];
      [correctionShadowView setTransform: moveUp];

      CGRect windowPos = [self convertRect: view.frame toView: nil ];
      [view removeFromSuperview];
      [self.window addSubview: view];
      view.frame = windowPos;
     }

    }
   }

  }

 }
}

"
__________________
APPS4LIFE
search for me in the app store.
orange gold is offline   Reply With Quote
Old 11-08-2010, 09:55 AM   #8 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
tharindufit is on a distinguished road
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Smile

Hi,

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.

Thanks for your kind replies.

Tharindu.
tharindufit is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone objective-c objc, spell checking, uitextview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 349
9 members and 340 guests
7twenty7, chiataytuday, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, mistergreen2011, Paul Slocum
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,660
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, laureix68
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0