iphone - CorePlot 缩放轴独立于多点触控

标签 iphone zooming core-plot axes

我有一个带有 CorePlot 图表的 iPhone 应用程序。我希望用户能够像默认功能一样放大和缩小图表,除了一件事:

  • 当用户水平捏合时 -> 缩放 x 轴。
  • 垂直 -> 缩放 y 轴。
  • 对角线 -> 缩放两个轴。

如何实现此功能?如有任何建议,我们将不胜感激。

最佳答案

正如 Felix Khazin 在他的 answer 中所显示的那样.

The way I do it is by adjusting the PlotSpace

代码在他的回答中。

实际管理垂直/对角线/水平手势。

1 创建 UIPinchGestureRecognizer

    UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]
                                                      initWithTarget:self action:@selector(handlePinchGesture:)];
            pinchGesture.delegate = self;
            [graphView addGestureRecognizer:pinchGesture];
            [pinchGesture release];

编辑

2 实现handlePinchGesture方法。

-(IBAction)handlePinchGesture:(UIPinchGestureRecognizer *)sender {

    switch (sender.state) {
        case UIGestureRecognizerStateBegan:
            //Store y and x coordinates of first and second touch
            break;

            case UIGestureRecognizerStateChanged:
            //check y and x coordinates of two finger touches registered in began state
            //to calcualte the actual pinch type:

            //Use scale property to find out if the pinch is zoom in or out

            if([sender scale] < 1) 
                NSLog(@"Zoom out");
            if([sender scale] > 1)
                NSLog(@"Zoom in");

            break;

        default:
            break;
    }
}

关于iphone - CorePlot 缩放轴独立于多点触控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6713206/

相关文章:

html - 如何在firefox中模拟css缩放?

iphone - 如何自定义核心图来模仿这种风格?

ios - 什么是好的 ios 图表库/框架

ios - Facebook iOS SDK : can't show a "direct message" dialog on iPad (works on an iPhone)

java - JComponent JPanel 缩放、平移和坐标问题

iphone - 我怎样才能在 cocos2d 中垂直而不是水平移动这些背景图像?

java - 使用Seek Bar缩放android Canvas

ios - 核心图 - 线下渐变

iphone - iOS 7 - XCode 5 - 约束

iphone - UITableView cellForRowAtIndexPath 问题