title: CoreTextView & UIScrollview : Calculating window size
body: <p>I am using <a href="https://github.com/giladno/UICoreTextView" rel="nofollow">CoreTextView</a> on iOS to render an html file in a UIScrollview that is set up programmatically. As soon as the html file exceeds a certain length, the text no longer renders. It does not seem to be a problem with: </p>
  
  <ul>
  <li><p>Memory. NSLog displays the entire NSAttributedString no matter how long it is. </p></li>
  <li><p>A formatting error in the html file. I was able to render the entire file in pieces. </p></li>
  </ul>
  
  <p>If I put in a very large height for the frame, same thing: <strong>empty screen and no errors to troubleshoot.</strong> I suspect that the issue has something to do with calculating file size and maybe... font line size? Stumped. Incidentally, if I enter a custom font, it is ignored and only the default Helvetica is displayed. Font SIZES, however, render correctly. Any help on getting the entire file to display would be much appreciated!  </p>
  
  <p><strong>My code:</strong> </p>
  
  <pre><code>m_coreText = [[CoreTextView alloc] initWithFrame:CGRectZero];
  m_coreText.backgroundColor = [UIColor clearColor];
  m_coreText.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
  
  NSString* html = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"terms" ofType:@"html"] encoding:NSUTF8StringEncoding error:NULL];
  m_coreText.attributedString = [NSAttributedString attributedStringWithHTML:html renderer:^id&lt;HTMLRenderer&gt;(NSMutableDictionary* attributes) {
                                   CustomRenderer* renderer=[[CustomRenderer alloc] init];
                                   renderer.type=attributes[@"type"];
                                   renderer.size=CGSizeMake(16, 16);
                                   return renderer;
                               }];
  m_coreText.frame = CGRectMake(0, 0, self.view.bounds.size.width, [m_coreText sizeThatFits:CGSizeMake(self.view.bounds.size.width, MAXFLOAT)].height);
  
  UIScrollView* scroll = [[UIScrollView alloc] initWithFrame:self.view.bounds];
  scroll.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  scroll.contentSize=m_coreText.frame.size;
  [scroll addSubview:m_coreText];
  [self.view addSubview:scroll];   
  </code></pre>