title: ensure layout in NSLayoutManager
body: <p>I have a UITextView with lots of text. The scrolling is mostly smooth on iPhones 4, 5, and 6, but on the 6 Plus there is lots of stuttering. (I believe this is because the 6 Plus is underpowered for the amount of pixels it has to push around). I notice that once I scroll past a region, if I scroll back over it, the scrolling is nice and smooth; layout has already been performed for the region and the processor doesn't have to do much. I want to force layout to occur before I get to the region. This is what I tried:</p>
  
  <pre><code>textView.layoutManager.ensureLayoutForTextContainer(textView.textContainer)
  </code></pre>
  
  <p>This doesn't appear to do anything at all. The scrolling is still not smooth on first pass over a region, and the before and after log statements have a difference of .00014 of a second. Just to make sure I was really getting the correct text container, I also tried:</p>
  
  <pre><code>textView.layoutManager.ensureLayoutForTextContainer(textView.layoutManager.textContainers[0] as NSTextContainer)
  </code></pre>
  
  <p>This also made no difference.</p>
  
  <p>What do I need to do to force layout of all text in the text container?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>EDITED TO ADD:
  To answer TheCodingArt's question: I'm not doing anything exotic in terms of the layout manager. This is my set up code:</p>
  
  <pre><code>var textStorage = NSTextStorage()
  var layoutManager = NSLayoutManager()
  textStorage.addLayoutManager(layoutManager)
  var textContainer = NSTextContainer(size: textContainerSize)
  layoutManager.addTextContainer(textContainer)
  
  textView = UITextView(frame: CGRectMake(0, 0, textViewWidth, textViewHeight), textContainer: textContainer)
  
  textView.showsHorizontalScrollIndicator = false
  textView.showsVerticalScrollIndicator = false
  textView.backgroundColor = UIColor.clearColor();
  textView.editable = false;
  textView.selectable = true;
  textView.scrollsToTop = false
  self.view.addSubview(textView)
  </code></pre>
  
  <p>Explicity instantiating and adding the text container and text storage is something I learned to do from the first answer to this question:
  <a href="https://stackoverflow.com/questions/19124037/scroll-to-bottom-of-uitextview-erratic-in-ios-7">Scroll to bottom of UITextView erratic in iOS 7</a>
  ...and which did help somewhat, but not enough for the 6 Plus.</p>
  
  <p>Later, I add text to it:</p>
  
  <pre><code>textStorage.appendAttributedString(attribStr)
  </code></pre>