2

I have a UITextView which I'm assigning a large amount of text to (~25 lines). It works fine if I don't define a font against the textview, but as soon as I set the font to be anything above size 13, then the text disappears completely (though still scrollable).

The other thing is that if I slowly type in text manually to reach the cross over point, the last line is split in two, and continuing to type just produces blank text.

Its as if the text view can only contain so much visible text and as soon as that is reached the text becomes blank.

Any suggestions welcome.

EDIT: Actually copying and pasting the above answer text into the text view, and then adding one more line is enough to make it start to turn invisible. Then when reloading the text view with the updated text (i.e answer above plus one line), its all invisible.

Setting the font size is enough to break it, just by doing systemFontOfSize: to 14. The actual font size which causes it varies depending on the amount of text in the text view.

Also using ARC.

AndyDunn
  • 1,074
  • 1
  • 12
  • 19
  • If you can post an example text string, and the font you are trying to use (provide he first "bad" one - the size where the problem manifests itself - I'd be glad to take a look. Just edit your question with this info. Also, using ARC or not? – David H Aug 17 '12 at 22:52
  • I've updated the answer now for you David. – AndyDunn Aug 18 '12 at 07:19
  • The textview is an outlet and contained in the view, or created in code? In the second case you would need a strong reference to it. Lastly, editable or not? – David H Aug 18 '12 at 12:00
  • Its not an outlet, but created in code in my own custom init method. Strong retention doesn't make a difference. And yes, its editable. – AndyDunn Aug 18 '12 at 14:45
  • Well, can you post code? Strong retention means, if its an ivar that's OK, if its a property, it better be strong not weak or assign. Thousands and thousands of people are using this control everyday - so obviously there is something not quite proper with yours. – David H Aug 18 '12 at 14:47
  • Check out the Paper Fold link below, and try adding a UITextView either on top of the map view or instead of the map view and see how you get on. – AndyDunn Aug 18 '12 at 14:49
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15509/discussion-between-david-h-and-andydunn) – David H Aug 18 '12 at 15:00
  • I have similar issue with Korean/Chinese/Japanese symbols: http://stackoverflow.com/questions/24845623/attributed-uitextview-doesnt-work-with-korean-symbols/24853543#24853543 – Dmitry Jul 20 '14 at 18:52

1 Answers1

0

So what I suggest you do is create a new single view project in Xcode, add a single UITextView to your view, and then manipulate it exactly as you are in the main project. You are doing something wrong - setting the font to nil, someone releasing the textView, or otherwise corrupting it. All messages to it MUST be on the main thread. Add asserts after any object property you are sending to the textView. As you can see huge font huge text is working just fine for me doing as I'm suggesting you do. The ideas is to start with something that works, keep adding code from your main project to the test project until you find exactly what you are doing that is causing the problem.

enter image description here

David H
  • 40,852
  • 12
  • 92
  • 138
  • Thanks for that. I have managed to get it working when its not being added to my own kind of subview. If its on its own its perfectly fine, but I'm adding it to the right hand side of this code https://github.com/honcheng/PaperFold-for-iOS .. I'm sure there is something funky going on with it but I can't pin point what. – AndyDunn Aug 18 '12 at 14:48