The contents of a UITextView occurs under a UINavigationBar

I have a UITextView inside a UIViewController that uses an automatic layout to snap it to 0 on all sides (so that it fills the entire screen). I am also viewing this view using the UINavigationController .

I got confused by a strange error, where if the UITextView has enough text to run from the screen, then the content is set under the UINavigationBar . If there is not enough text to fill the screen, the text layout does not fall under the UINavigationBar .

Here's what happens when there is enough text that it disconnects from the screen, and you need to scroll it to see everything.

enter image description here

I tried:

  • Configuring the insertion of UITextView content.

  • Make sure the UINavigationBar not translucent.

  • Tried setting self.automaticallyAdjustsScrollViewInsets = NO;

+5
source share
2 answers

Inside viewDidLoad viewController where your textView is located, add this:

 self.edgesForExtendedLayout = UIRectEdgeNone; 
+2
source

I am not sure why the problem occurred, but this is fixed:

 - (void)viewDidLayoutSubviews { if (self.textView) { [self.textView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO]; } } 
0
source

All Articles