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.
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:
this how looks after manually scroll top.
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)]; }