views:

612

answers:

1

I have a UITextView that I'm trying to keep hidden from the user, except I'm using it's autocorrect interface so I can't just put it's hidden property to true.

Currently I am putting the contentOffset such that it hides the first line of text, however this does not consistently work. Sometimes it does, other times the scroll view re scrolls to where the text is partially visible. It seems arbitrary which it does, as without changing a line of code, the behavior will switch by itself after I rebuild...

I have tried turning off scrolling for the UITextView, as well as overriding the UITextView's drawRect function to not do anything, as well as changing the TextColor of the UITextView to clear color. It seems that you cannot change the alpha values of text colors so that did not work.

Any other ideas on how to achieve this? Thanks in advance.

A: 

Perhaps the UIScrollView is trying to be smart about where it is automatically scrolled to, even though you have disabled user scrolling?

You could try manipulating the contentOffset, and see if controlling that value stops the unwanted scrolling.

Another idea to help debug any unwanted scrolling activity is to add debug NSLog statements into a few of the key methods of UIScrollViewDelegate, such as scrollViewDidScroll: or scrollViewShouldScrollToTop:. If the contentOffset approach fails, this might help you understand what is going wrong, and possibly prevent it at the delegate level.

By the way, it sounds like what you're doing in general is kind of hacky. You might end up with more to-the-point answers (and cleaner code) by just asking about your true goal - maybe having your own version of spell checking?

Tyler
It is pretty hacky :). Basically I just want the Kanji choosing interface for Japanese input that the UITextView and TextFields have automatically. But I'm displaying the text in multiple colors/sizes which is something UITextViews and Fields do not support. So I'm using a hidden UITextView for input which was fine before I needed the chooser because I just set it to hidden. But now that I need the Kanji chooser and don't know of any existing API for it, I need to hide the text while still showing the chooser :(
kiyoshi
Tyler
UIWebView was what I tried first but it's finicky and I'd rather not replace all the html tags during edits, plus load times are annoying. It's okay, I've got a good way of drawing the text, and I think using a hidden textview for input purposes isn't too hacky, just for the Japanese stuff I need to do the cheesy hiding stuff. I found if I tap into scrollViewDidScroll I can reset the contentOffset there, and add in a variable so that it doesn't start recursively going to scrollViewDidScroll... It works-ish though :) thx for the help ^^
kiyoshi