UITextView text not displayed when parent view is UIScrollView UNTIL I scoll?

Looks like the views that you are setting up are not refreshed. And when you interact with the views then they are refreshed and your changes are rendered to the display...

Up vote 1 down vote favorite share g+ share fb share tw.

I have a UITextView inside of a UIScrollView that is configured offscreen when the code below runs in my ViewController's viewDidLoad. Unfortunately, if the "eventDetails" text is particularly long nothing is displayed inside the UITextView until I interact with it (e. G click inside and drag for example).

My question: How to have it so the text is displayed in the UITextView WITHOUT forcing the user to interact with the UITextView first? Here is the code: UITextView *txtDetails = UITextView alloc initWithFrame:CGRectMake(-4, yOffset, page3ScrollView.frame.size. Width, 0); txtDetails setEditable:NO; txtDetails setScrollEnabled:NO; txtDetails setFont:UIFont systemFontOfSize:12; txtDetails resizeAndSetTextWithMaxSize:CGSizeMake(txtDetails.frame.size.

Width, 999999999) forText:eventDetails withAdditionalHeightOf:16. F; page3ScrollView addSubview:txtDetails; CGRect frame = txtDetails. Frame; frame.size.

Height = txtDetails contentSize. Height; txtDetails. Frame = frame; page3ScrollView setContentSize:CGSizeMake(page3ScrollView.frame.size.

Width, txtDetails.frame.origin. Y + txtDetails.frame.size. Height); Thanks iphone objective-c ios uiscrollview uitextview link|improve this question edited Jul 30 '11 at 11:01rptwsthi2,0661420 asked Jul 30 '11 at 9:28wgpubs1,40521639 86% accept rate.

Looks like the views that you are setting up are not refreshed. And when you interact with the views then they are refreshed and your changes are rendered to the display... Try adding txtDetails setNeedsDisplay; page3ScrollView setNeedsDisplay; after your code in viewDidLoad. If it will help then maybe we'll find some more elegant solution...

Tried this already and unfortunately it didn't affect the UI at all. Like I said above, the weird thing is that I only get this behavior if the text for the UITextView is somewhat long. Anyhow, thanks for trying.

– wgpubs Jul 30 '11 at 18:26.

I was able to get this working by setting the UITextView's text ONLY when needed (e.g. Is about to come on screen). Below is the relevant code: - (void)scrollViewDidEndDecelerating:(UIScrollView *)sv { if (sv == scrollView) self updatePagedView; } - (void)updatePagedView { int currentPage = pageControl. CurrentPage; // *** loadDetailsPage3 is where I set the text *** if (currentPage == 2) { self loadDetailsPage3; } } If anyone has a better solution or needs more explanation just hit me up in the comments.

I've had the same issue and it's taken me several hours to find a suitable fix for it... Here's what I came up with... -(void)DidBecomeActive { if (!DidUpdateBounds) { DidUpdateBounds = true; // instance variable set to false on load NSString *oldtext = uiTextView. Text; //The trick is (1) removing it from it's superview // (2) resetting it's 'text' property // (3) re-adding it to the view WHILE it's on-screen. UiTextView removeFromSuperview; uiTextView.

Text = oldtext; self. View addSubview:uiTextView; self. View setNeedsDisplay; } } I'm using CoreAnimation to switch to this view.

So right before I execute that code, I call this //The 0,-300,480,300 is bounds of the UIView my offscreen UITextview is on self.view. Layer setBounds:CGRectMake(0, -300, 480, 300); // SetNeedsDisplay, then call my method above to //FORCIBILY redrew the UITextView while it's effectively on-screen self. View setNeedsDisplay; TextLogVC DidBecomeActive; //CoreAnimation then goes here This solves the issue.

After setting the layer. Bounds it redraws the control(UITextView) and it thinks it's onscreen. Then CoreAnimation takes care of animating from my current UIView to the new UIView and all of the text in the uiTextView is displayed throughout the animation.

Hope this helps,-Szh.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions