Reputation: 1
I config a textView in a UIViewController like following: textView configuration
but when controller viewDidAppear
I found that UITextView's contentSize = {375, 242}
and UITextView can not scroll.
But if i tap the textView, let the textView begin editing (but edit nothing), then i touch the controller's view let textView endEditing, log the textView, this time contentSize = {375, 361}
and UITextView can scroll.
Is anybody know why? Thanks.
Upvotes: 0
Views: 165
Reputation: 6635
NSTextContainer
has a property called heightTracksTextView
which may be interfering with your setup here, as the default is false.
I would double check the height of the NSTextContainer
after you initialize the UITextView
and after you add the UITextView
to the view hierarchy.
Check the documentation here: https://developer.apple.com/reference/uikit/nstextcontainer/1444559-heighttrackstextview
If that doesn't help, let me know, I know I've solved this issue before, but I'm not at my computer right now.
Upvotes: 0
Reputation: 27448
You can add textView
something like,
UITextView *standardTextView = [[UITextView alloc]initWithFrame:CGRectMake(20, 50, self.view.frame.size.width - 40, 120)];
standardTextView.layer.borderWidth = 1.0;
standardTextView.layer.borderColor = [[UIColor lightGrayColor]CGColor];
standardTextView.delegate = self;
standardTextView.font = [UIFont fontWithName:@"Helvetica" size:17.0];
[self.view addSubview:standardTextView];
then when your content(i.e text) will be bigger than textview's height
it will enable scroll otherwise it remains disable!!
Upvotes: 0