Does anybody know a way to make the axis fixed on a CPTXYGraph when the graph itself is inside a UIScrollView?
To clarify, I have a CPTXYGraph displaying data that is wider than the current screen, so I placed it inside a UIScrollView with horizontal scrolling (I’m aware of the userInteractionEnabled property core-plot exposes, but I need to keep the acceleration and other benefits of UIScrollView). I need the Y axis to be fixed on the left of the screen, something I would usually do in the layoutSubviews method of the UIScrollView. My first guess was to just apply a transform to the CPTXYAxis corresponding to the current contentOffset (considering it inherits from CALayer), but that seems to have no effect. I’ve also played around with the orthogonalCoordinateDecimal property but it looks like a dead-end.
Is there anybody out there that has managed to make this work?
For the benefit of anyone looking to solve this problem too, my solution:
You can use
CPTConstraintsto position the axis, so I have done the following in myUIScrollViewsubclass:This code can be repurposed for all fixed axis positions using the different initializers for
CPTConstraints.