title: Annotate table view on iPad Pro with Pencil
body: <p>I'm building an app for the iPad Pro that has a UITableView showing a catalog with items. There are many catalogs each with 1-thousands of items.</p>
  
  <p><strong>Goal</strong></p>
  
  <p>I would like to find out how to (best) make it possible to annotate stuff in the UITableView using Pencil so that the user can scroll with the finger. Also, what the user has drawn is persisted in the data model.</p>
  
  <p>Let me explain what I have tried.</p>
  
  <p><strong>Single UIView</strong></p>
  
  <p>I put a single UIView on top of a custom UITableView that overrides the <code>touchesBegan/Moved/Ended/Canceled</code> functions and filters on <code>touch.type == UITouchType.Stylus</code> to know when it's the finger and when it's Pencil. That works but it's not a good solution as the image will be huge and not even possible to put for some catalogs with too many items.</p>
  
  <p><strong>Per row a UIView</strong></p>
  
  <p>Works well with a large catalog, but a problem came up with not being able to draw across rows which must be possible. I didn't yet find a way to keep the gesture across different views. Is this possible or is there some kind of workaround?</p>
  
  <p><strong>Fixed UIView on screen</strong></p>
  
  <p>Follows when scrolling, easy to draw across anything, but unclear and difficult to fix drawn stuff to table coordinates as well as persist it. It didn't feel right as it seemed overly complex to maybe have the screen-sized canvas to follow and anything drawn is converted to an UIImageView for the rows it spans and persisted there...this is where I am now and I can show some code if this approach makes sense.</p>
  
  <p>Is there a better approach to this as it seems to me this should be a very natural need now with Pencil, i.e. to annotate and persist in a table view.</p>
  
  <p>Has anyone done something like this or is there something I have overlooked? Maybe some kind of sparse UIImageView so I can have a single across a massive table?</p>
  
  <p>I'm looking for a good solution and example code depending on how involved the solution is.</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So to clarify, the items in the table are ordered in a fixed way so one can use that to persist the drawn/annotated stuff as partials. </p>
  
  <p>Generally, the drawings/annotations can be persisted as anything from 1 to N images. One image is in many cases too big as the items are many thousands, N images means there is a border where a gesture is interrupted and that is not ideal for usability as the drawing isn't continuous (unless this is possible to solve which would be great).</p>
  
  <p>The data model can be catalog [ -> pages ] -> items but I would not like to have a page concept as it (longer reason short) makes the items per page smaller and the whole point is to maximize the items to it's easier to annotate.</p>