UITextView when set to UITableViewCell sometimes does not display content

I wonder if anyone else is facing the same problem. I have a UITextView field placed in a UITableViewCell. Sometimes it does not display text. When I click or browse a table view, it appears. Any guesses?


More details:

I call a method in the viewDidLoad method that calls a web service to retrieve some data. When receiving data, I set the values ​​of UILabel and UITextView. The UILabel values ​​look great, but the UITextView (sometimes) doesn't display the value until I go into subview or go up and down to view the area associated with the UITextView. I am showing UILabel and UITextView objects in a UITableViewCell. I call [tableView reloadData] immediately after setting the values ​​in UILabel and UITextView, but I do not recreate the UITableViewCell.

Thanks for your answer and pointers.

+4
source share
4 answers

I solved this by calling [myTableView reloadData];

+3
source

I had the same problem more or less: a UITextView inside a custom subclass of UITableViewCell didn't display its text until you touch (and thus scroll) the UITextView. This will only happen with the FIRST cell in the table. I could not understand why this was happening, but the problem was easily fixed by pushing the UITextView contentOffset programmatically.

 problemCell.textView.contentOffset = CGPointMake(0.0, 1.0); problemCell.textView.contentOffset = CGPointMake(0.0, 0.0); 
+3
source

This may have something to do with the fact that UITextView and UITableView are subclasses of UIScrollView. So you have a scroll view inside the scroll, and that would not surprise me if that were the cause of your problems.

If you do not need to edit the text in the table, just use the multi-line UILabel.

If you absolutely need to have a UITextView inside a UITableView, perhaps disabling scrolling on one of them can also fix the problem. (I think the property name is scrollEnabled or scrollingEnabled .)

+1
source

Make sure you call [super viewWillAppear:] and [super viewDidAppear:] in all places where you override viewWillAppear or viewDidAppear.

This is probably true for all other types of viewDidWhatever and viewWillWhatever.

The problem you are facing indicates that the UITextView does not receive the message to draw itself on the screen when you first show the table, but receives the message when it needs to be updated.

0
source

All Articles