ios - UITextView is partially scrolled down when view opened -


i create uitextview , add lot of text it. when launch view, uitextview partially scrolled down. of cause user can scroll up, feels weird.

what happens? did miss obvious settings?

please refer following image. part of text cut out. borrow text link.

enter image description here

i started simple single view application. how viewdidload looks like:

- (void)viewdidload {     [super viewdidload];      nsstring* path = [[nsbundle mainbundle] pathforresource:@"license"                                                      oftype:@"txt"];     nsstring* terms = [nsstring stringwithcontentsoffile:path                                                 encoding:nsutf8stringencoding                                                    error:nil];     self.textfield.text = terms; } 

and storyboard:

enter image description here

this how looks after manually scroll top.

enter image description here

add line @ end of viewdidload:

[self.textfield scrollrangetovisible:nsmakerange(0, 1)]; 

like this:

- (void)viewdidload {     [super viewdidload];      nsstring* path = [[nsbundle mainbundle] pathforresource:@"license"                                                      oftype:@"txt"];     nsstring* terms = [nsstring stringwithcontentsoffile:path                                                 encoding:nsutf8stringencoding                                                    error:nil];     self.textfield.text = terms;     [self.textfield scrollrangetovisible:nsmakerange(0, 1)]; } 

Popular posts from this blog