If I add series markers through chartView:viewForMarkerInSeries:withItem:index:originalSourceItemdisplayOptions:, whenever I scroll and a marker is on screen the chart gets layoutSubviews called.
I have a few workarounds to the limitations of the framework in layoutSubviews. Is there a way to get markers on screen out of the box without relying on layoutSuviews?
I'm pretty sure the answer is no, but just want to double check.
Hi Rogelio,
I'm not seeing layoutSubviews getting called on zooming or panning. I'm attaching a small sample I used to test this. Maybe something else is happening in the custom marker code. If you could modify the sample to reproduce the issue, I can look into it.
Thanks
The culprit was this:
options.displayAsImage = NO;
But the reason I turned that off was because tapping on a marker won't trigger chartView:tapForSeries:withItem:atPoint:. So my workaround was to have the markers render as views in order to turn off userInteractionEnabled and thus get chartView:tapForSeries:withItem:atPoint: called.
Anyway to enable chartView:tapForSeries:withItem:atPoint: getting called even when there's a marker on top of the point?
When markers are drawn as images, they're drawn directly to the chart's graphics context. Unfortunately, this takes away the ability to interact with the series under the marker. When markers are shown as views, they're added to the chartView as subviews, which triggers layoutSubviews. And since markers have to be re-rendered when you zoom and pan, the custom marker code gets hit quite alot, re-adding markers and going through layout.
Can you explain why it's a concern for you that layoutSubviews gets called so much? If we moved custom markers to another container in the chartView you wouldn't get all those calls to layoutSubviews, but that marker container would and it wouldn't really be an improvement (at least performance-wise)