1

I am using a UITextView and assigning some text in my code but for some reason it always starts after 5-6 lines. The UITextView is an AttributedTextView or allows Attributed strings.

enter image description here

 self.bodyTextView.selectedRange = NSMakeRange(0, 0);
 self.bodyTextView.font = [UIFont fontWithName:@"Cochin" size:17];
 self.bodyTextView.text = @"This is written by Joe. This is written by Moo. This is written by Qoo";
Piyush Dubey
  • 2,416
  • 1
  • 24
  • 39
john doe
  • 9,220
  • 23
  • 91
  • 167
  • try setting the UITextView's `automaticallyAdjustsScrollViewInsets` to NO. See if that does anything. – Putz1103 Jan 14 '14 at 21:43
  • There is no such property on the UITextView control. – john doe Jan 14 '14 at 21:45
  • well bugger. I got that answer from http://stackoverflow.com/a/19468461/1671729. Give it a look and see if it answers you at all. – Putz1103 Jan 14 '14 at 21:48
  • Unfortunately, it does not help! I am not using ScrollView. I am using a UITextView and the bottom is UITabbar. I cannot even find the property you are mentioning. – john doe Jan 14 '14 at 21:54
  • Try here: http://stackoverflow.com/a/18932245/1671729. Apparently that property is on the containing view controller. – Putz1103 Jan 14 '14 at 21:58

1 Answers1

2

To quote this answer:

A text view is a scroll view. iOS 7 will add a content offset automatically to scroll views, as it assumes they will want to scroll up behind the nav bar and title bar.

To prevent this, override the new method on UIViewController, automaticallyAdjustsScrollViewInsets, and return NO.

It deals with the Navigation bar overlapping the UIViewController's view's frame. When that is set to no then the UIViewController does not adjust anything to avoid the top navigation bar.

Instead of subclassing and overloading, you can just set the property to no.

(UIViewController).automaticallyAdjustsScrollViewInsets = NO;
Community
  • 1
  • 1
Putz1103
  • 6,211
  • 1
  • 18
  • 25