title: UIView with CATransform3D inside a UITableViewCell = Choppy Scrolling
body: <p>I'm using a custom <strong>UITableViewCell</strong>, into which I am placing a subclassed <strong>UIView</strong> (within <code>contentView</code>, natch). The <strong>UIView</strong> in question displays a directional arrow and two lines of supporting text.</p>
  
  <p>The arrow is displayed by means of a layer with a background color and an arrow-shaped mask. The background color changes to one of two possibilities depending on the direction the arrow is pointing.</p>
  
  <p>The view receives a <strong>NSNotification</strong> whenever it needs to update the arrow (based on, but not identical to, the current heading - each cell and view is different). When it receives notice, the view calls a private method to perform a transform. This animates the arrow layer, effectively rotating it around its center to a new direction, like so:</p>
  
  <pre><code>    // Update layer BG color, then ...
  
      [UIView setAnimationBeginsFromCurrentState:YES];
      CATransform3D transform = CATransform3DMakeRotation(DegreesToRadians(locationDirection), 0, 0, 1);
      _arrowLayer.transform = transform;
  </code></pre>
  
  <p>(n.b.: <code>_arrowLayer</code> is for internal use only, and is not exposed through a property.)</p>
  
  <p>There is also a property on the <strong>UIView</strong> to set info used to create the supporting text. When this is changed, <code>setNeedsDisplay</code> is invoked, the <code>drawRect:</code> method makes the calculations and draws the resulting text.</p>
  
  <p>That's all well and good. However, <strong><em>there is one major problem</em></strong> I'm encountering:</p>
  
  <p>Scrolling the table view at the same time the arrows are animating results in some major league choppy scrolling, often to the point of the scrolling stopping short! Even when this is the only view in <code>contentView</code> (in the name of minimal test cases), it doesn't matter.</p>
  
  <p>If the device is not moved, scrolling is moderately acceptable, but still open to improvement.</p>
  
  <p>I'm hopeful that I'm simply making a fundamental error (Don't use <code>drawRect:</code>? Do the transform some other way? None of the above?)</p>
  
  <p>Thanks in advance for any clues/advisement!</p>
  
  <p><strong>UPDATE 4 Oct 2011:</strong> I tried having the <strong>UITableViewController</strong> watch <strong>UIScrollViewDelegate</strong> (per the <strong>UIScrollView</strong> programming guide) for when scrolling starts/stops, then each directional arrow view asks its delegate (the Table VC in this case) if it's OK to animate. This doesn't help much either though. If animation is in progress, we're out of luck. Perhaps <strong>NSNotification</strong> is in order, with the directional arrow view looking for a certain notification. (That sounds a bit backwards though, doesn't it? Giving <em>other</em> objects a notification that they can send out? Hmm.)</p>