iOS7 - UITextView leave extra padding at top in Storyboard

725 views Asked by At

Tools Specification:

  • OS X Yosemite 10.10
  • Xcode 5.1.1

Today I found one weird issue (Or may be if i'm wrong with new specialisation or something else. Please make me correct if anything is wrong).

I created project using Xcode 5.1.1 for iOS 7.1 OS with Storyboard support. Everything here is default. Now just drag and drop UITextView into view of UIViewController (It is embedded in UINavigationController more precisely).

Here all properties of UITextView are default except background color (Change to highlight border of UITextView). I see that the default text in UITextView goes bottom when I change its height. Also left some space on top and than text is rendered. See the below image:

Misleading space at top

Run application to check this also in simulator. And it shows extra space on the top of UITextView.

enter image description here

I also did the same in Xcode 6.0.1 to double sure that this is not default behaviour. And it is perfect in Xcode 6.0.1, there were no extra space on top of content of UITextView.

enter image description here

Spotlight:

I never did face this issue before. I updated Mac OS Yosemite two days ago (If its relevant to the Mac OS).

Also one thing is to be note that if I remove embedded UINavigationController than it works normal.

So is it related to OS? OR Do I miss something, I mean Apple introduce or change any behaviour?

Note: There is no any constraints. Just drag and drop UITextView to view.

2

There are 2 answers

3
Boris Gafurov On

EDIT: Just updated to XCode6.1 and I am building onto iPad with iOS7.1 - THE SAME ISSUE PERSISTS!

I think it is a bug in XCode5.1.1, here is what I found, may be it will help you, it did help me.

EDIT: Hey, just discovered that UITableView does exactly the same, it appears scrolled down if it is 1st in a list in interface builder, same trick cures it.

Here I have my textview 1st in the list in interface builder: enter image description here

and it is scrolled down when you run the app: enter image description here

However, if I move my textview below the others: enter image description here

It shows up in the app all right: enter image description here

So, just make sure none of the textviews (or tableviews) are 1st in the list in interface builder! Seems like real bug to me, will log it in with Apple.

4
jomafer On

I think you can fix this by setting the property contentOffset as follows:

yourTextView.contentOffset = CGPointZero

This allow you to set the text at top of the UITextView's frame.