0

I have a UITextView with a lot of text in it. When the subview containing the UITextView is shown the UITextView only appears after the UITextView has been touched and scrolled.

Is there a limit of how much text can be in a UITextView? Or is this a bug?

attached is a clip explaining this occurrence.

https://dl.dropbox.com/u/8256776/UITextView%20Bug.MOV

OscarTheGrouch
  • 2,374
  • 4
  • 28
  • 39
  • If there is a text limit in `UITextView` you have not hit it yet as I have a text view containing much much longer texts. Can you say something about how the text is set in the text view. And how the text view is added, etc. – pajevic Aug 30 '12 at 13:15
  • At first I pastEd it from a word document to Interface builder and that give these results. Then I tried pasting the text and set it as NSString and set the UITextView.text to that NSString in the viewDidLoad but it gave the same results. – OscarTheGrouch Aug 30 '12 at 18:18
  • It's really hard to try to figure out what goes wrong without any code snippets or any insight of how the views are added etc. – pajevic Aug 31 '12 at 06:56
  • I did everything with the UITextView in interface builder. I placed a UITextView into a subview then just pasted text from a word document into the UITextView.... I noticed if I made the size of the text 10 pt it is visible with out touching the UITextView...but If I change the size to 11 or bigger the text isn't visible until after it is touched. – OscarTheGrouch Sep 01 '12 at 02:33
  • the text in this doc is the text pasted into the UITextView https://dl.dropbox.com/u/8256776/Disclaimer_General.doc – OscarTheGrouch Sep 01 '12 at 02:44
  • Well, I have tried making an test app based on what you describe and what I saw in the video and it works just fine. There must be something specific in your setup that gives this special behaviour. Could you make a small project with just the necessities to reproduce the issue and then post a link to it here. I'll be glad to take look at it, but as it is right now I simply can't reproduce your problem. – pajevic Sep 01 '12 at 06:48
  • Thank you so much, I have uploaded the entire project to drop box https://dl.dropbox.com/u/8256776/TestApp.zip you can see the issue in the disclaimer and the DUI information – OscarTheGrouch Sep 01 '12 at 13:10

1 Answers1

2

Ok, I have looked into it and it seems to be quite a common issue. It seems that the text view doesn't feel that it has to draw the text, but calling setNeedsDisplay doesn't help. I don't know if there is a "real" solution, but you can force it to draw the text by scrolling programmatically:

disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);

An unrelated thing in your code: In your switchView method you have two animations, one for the menu view and one for the view you are sliding into place. This is unnecessary as you can put both setFrame calls in the same animation:

MenuView = (UIView *)[self.view viewWithTag:100];
appView = (UIView *)[self.view viewWithTag:ViewInt];
[MenuView setFrame:CGRectMake(0, 0, 320, 480)];
[appView setFrame:CGRectMake(321, 0, 320, 480)];
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:.5];
[MenuView setFrame:CGRectMake(-320, 0, 320, 480)];
[appView setFrame:CGRectMake(0, 0, 320, 480)];
disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);
[UIView commitAnimations];

And one more thing (and then I will back off :) ) You seem to be quite fond of using tags to retrieve elements. While it does work, it is not very understandable. You don't have that many elements so I would just add each of them as IBOutlet with a meaningful name (like you did with your disclaimerView). Also, have seperate switchView methods for the different views you are moving into place. That way you can easily perform additional stuff you might need for just that view, like the force scroll on disclaimerView.

pajevic
  • 4,607
  • 4
  • 39
  • 73
  • thanks for all the helpful hints. I didnt know that you could set multiple animations in the same block. The reason I use using the tags is, i couldnt think of an elegant way to call a subview from one button with out naming all the subviews. All great information, thanks so much. – OscarTheGrouch Sep 01 '12 at 18:50
  • Funny you should say "block" because it actually reminds me that since iOS 4.0 the recommended way of doing animations is actually using blocks, for instance using the method `animateWithDuration:animations:`. Using `beginAnimations`/`commitAnimations` is discouraged, although I don't believe that they are deprecated yet. – pajevic Sep 01 '12 at 21:06