Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPinchGestureRecognizer how to use it correct?
    primarykey
    data
    text
    <p>I have a simple chart control that display some lines. There are 3 properties involved in chart painting:</p> <ul> <li><code>RecordCount</code></li> <li><code>FirstVisibleIndex</code></li> <li><code>LastVisibleIndex</code></li> </ul> <p>Everything works ok, chart paints just fine between First &amp; Last Visible Record. Now I want to let user zoom in &amp; out the chart using 2 fingers, so I subscribed to <code>UIPinchGestureRecognizer</code> and implemented such a routine.</p> <pre><code>-(void)handleZoomGesture:(UIGestureRecognizer *)sender { if (_isChartBusy) { return; } UIPinchGestureRecognizer *gr = (UIPinchGestureRecognizer*)sender; if (gr.state != UIGestureRecognizerStateChanged &amp;&amp; gr.state != UIGestureRecognizerStateEnded) return; CGFloat scale = gr.scale; if (scale == 1) { return ; } if (_prevZoomScale == 0) { _prevZoomScale = scale; return; } int startIndex = chart.FirstVisibleIndex; int endIndex = chart.LastVisibleIndex; NSLog(@"Zoom. Scale: %f", scale); int stepZoom; int cnt = chart.LastVisibleIndex - chart.FirstVisibleIndex; stepZoom = cnt * 0.05; if (scale &lt; _prevZoomScale) { startIndex -= stepZoom; endIndex += stepZoom; } else { startIndex += stepZoom; endIndex -= stepZoom; } _prevZoomScale = scale; if (endIndex &lt; startIndex || (endIndex - startIndex) &lt; 10) { return; } if (startIndex &lt; 0) { startIndex = 0; } if (endIndex &gt;= [chart.DataProvider GetBarRecordCount]) { endIndex = [chart.DataProvider GetBarRecordCount] - 1; } if (startIndex == chart.FirstVisibleIndex &amp;&amp; endIndex == chart.LastVisibleIndex) { return; } chart.FirstVisibleIndex = startIndex; chart.LastVisibleIndex = endIndex; [self setNeedsDisplay]; } </code></pre> <p>it kinda works, but very unstable, chart gets "jumpy" when I try to move fingers and make the zoom operation. I cannot simulate a nice and smooth zoom in &amp; out experience. Are there any best approaches to achieve such a smooth change of VisibleIndexes in relation to how many Records I have in chart and how many are visible.</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.
 

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