2

I have a programatically populated storyboard text view.

[textView setFont:[UIFont boldSystemFontOfSize:11.0f]];

    textView.text = @"Why oh why is this happening to me?! This seems like a pretty absurd problem to be having.";

This is how the text box loads. The text box is created between the image you see at the top and the two images you see at the bottom and it fills the whole space in-between.

Shot of how texts looks on loading

How the text box looks if I scroll up (and how I want it to appear). It seems like there are a bunch of unwanted lines populating the text box before my text?!

How the text box looks if I scroll up

So I have tried fixing the height and width of the text box using constraints, I have tried stopping the view scrolling and I have tried setting the content insert parameter of the text box. None of these things helped.

Anyone got any suggestions as to why this is happening?

I'm not sure if this is related, but the only change to this view controller recently has been making the navigation bar translucent.

Community
  • 1
  • 1
Andy A
  • 236
  • 3
  • 12
  • Firstly, I'd recommend changing the background color of your textview to make sure it is the size you think it is. – Will Jenkins Oct 30 '13 at 11:34
  • Hi Will, yeah this is one of the first things I checked. Ill post a screen shot with it white if you want. It also stands to reason that since I can scroll the text to where it is in the second screen shot the text view is at least that big. Anymore ideas? Im pretty confused here! – Andy A Oct 30 '13 at 11:37
  • change background color of text view... and check for frame ..first – Raon Oct 30 '13 at 11:41
  • @Raon changing the colour of the background was the first thing I checked Raon. I can scroll the text up like in the second screen shot, so the frame is correct. – Andy A Oct 30 '13 at 12:14
  • Weird stuff like this can be caused by auto layout with bad constraints. If it's on, turn auto layout off and see what happens. – Will Jenkins Oct 30 '13 at 12:31
  • @WillJenkins Just tried that will, didn't help! I also tried removing all constrains and manually resetting them all. I also tried replacing the text box entirely. Please tell me you have some more ideas? – Andy A Oct 30 '13 at 12:47
  • You said "the only change to this view controller recently" - did it used to work? – Will Jenkins Oct 30 '13 at 12:59
  • 1
    Also, did you see this question/answer? http://stackoverflow.com/questions/19468417/ios-7-uitextview-vertical-alignment – Will Jenkins Oct 30 '13 at 13:03
  • @WillJenkins Thank you for directing me to that question, it had the answer! A new feature of iOS7 means there is an inset automatically added by the nav and status bar. This was what was causing my issue. All I had to do was unselect the 'Adjust Scroll View Insets' when I had the view controller selected and my problem was fixed. If you want to put that in a question Will I'd be happy to mark it as correct! – Andy A Oct 30 '13 at 13:44

1 Answers1

4

See this question and answer

You need to select the parent view controller and unselect the 'Adjust Scroll View Insets'

:o)

Community
  • 1
  • 1
Will Jenkins
  • 9,507
  • 1
  • 27
  • 46
  • 1
    Note too, that you often have to call for layout: `view.layoutIfNeeded()`. It's very annoying and exceptionally badly done in iOS. – Fattie Feb 24 '17 at 04:38