Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewCell error loading UIWebView
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/fTRlj.png" alt="Screen capture"></p> <p><img src="https://i.stack.imgur.com/abgZI.png" alt="Screen capture"></p> <p>As you can see there is an error. I'm loading a UIWebView on each UITableViewCell. The problem is that when it loads a large amount of data the UITableViewCell disappears and when I scroll the text overlay itself.</p> <p>Maybe there is a max height for a UITableViewCell?</p> <p>It's another error?</p> <p>What can I do?</p> <p><strong>Edit:</strong> this is the viewController code that manages the API response and store each 'post' as a UIWebView, wich is loaded in the main view and the UITableViewCell contentView. The question is: where is the problem with large webViews? code? max height? memory?</p> <pre><code>#import "TopicViewController.h" #import "HTMLController.h" NSString *_topicID; @implementation TopicViewController @synthesize heightForView = _heightForView; @synthesize tableView = _tableView; @synthesize htmlController = _htmlController; @synthesize pageCounter = _pageCounter; + (void)setTopicID:(NSString *)topicID { _topicID = topicID; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { } return self; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; self.heightForView = [[NSMutableDictionary alloc] init]; self.htmlController = [[HTMLController alloc] init]; [self.htmlController requestTopicWithID:_topicID]; NSInteger viewTag = 117; for (NSString *html in self.htmlController.postsContent) { NSString *formattedHTML = [NSString stringWithFormat:@"&lt;div style='overflow: hidden; max-width: device-width;'&gt;%@&lt;/div&gt;", html]; NSLog(@"%@", formattedHTML); UIWebView *content = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 300, 1)]; content.tag = viewTag; content.alpha = 0; content.opaque = NO; content.backgroundColor = [UIColor clearColor]; content.scrollView.scrollEnabled = NO; content.scalesPageToFit = NO; content.delegate = self; [self.view addSubview:content]; [content loadHTMLString:formattedHTML baseURL:[NSURL URLWithString:@"http://www.elotrolado.net"]]; NSLog(@"loading wv %i", viewTag); viewTag++; } } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - TableViewDelegate &amp; DataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.heightForView count]&gt;0 ? [self.heightForView count] : 0; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return nil; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return [self.heightForView count]&gt;0 ? [[self.heightForView objectForKey:[NSString stringWithFormat:@"%i", indexPath.section+117]] floatValue]+20.0 : 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = [NSString stringWithFormat:@"%i", indexPath.section]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; UIView *content = [self.view viewWithTag:(indexPath.section+117)]; content.alpha = 1; [cell.contentView addSubview:content]; } return cell; } - (void)webViewDidFinishLoad:(UIWebView *)webView { CGRect frame = webView.frame; frame.size = [webView sizeThatFits:CGSizeZero]; frame.size.width = 300; webView.frame = frame; [self.heightForView setObject:[NSString stringWithFormat:@"%f", frame.size.height] forKey:[NSString stringWithFormat:@"%i", webView.tag]]; if ([self.heightForView count]==[self.htmlController.postsContent count]) { NSLog(@"All wv loaded"); [self.tableView reloadData]; } else NSLog(@"wv %i loaded", webView.tag); } @end </code></pre> <p>This code works with most webViews but it doesn't with large ones</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload