I have a UITextView
inside a UIViewController
that uses auto layout to pin it to 0 on all sides (so it fills the whole screen). I also have this view being pushed using UINavigationController
.
I'm running into a weird error where if the UITextView
has enough text so that it runs off the screen, then content gets set under the UINavigationBar
. If there is not enough text to fill the screen the layout of the text doesn't go under the UINavigationBar
.
Here is what's happening, this is when there is enough text that it goes off the screen and you need to scroll to view all of it.
I've tried:
Setting the content inset of the UITextView
.
Made sure the UINavigationBar
isn't translucent.
Tried setting this self.automaticallyAdjustsScrollViewInsets = NO;
Inside viewDidLoad of viewController where your textView is, add this:
self.edgesForExtendedLayout = UIRectEdgeNone;
I'm not sure why the problem was occurring but this fixed it:
- (void)viewDidLayoutSubviews {
if (self.textView) {
[self.textView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With