【问题标题】:How can I resize the uiview like that of uiimageview on uiscrollview?如何调整 uiview 的大小,就像 uiscrollview 上的 uiimageview 一样?
【发布时间】:2011-12-03 12:37:05
【问题描述】:

我需要为用户提供裁剪图像的功能。我在一个视图上显示 uiimageview,并且正在显示另一个视图,该视图像一个小盒子一样可移动。移动盒子时,它会给我坐标,并且我将从 uiimageview 创建一个新图像。通过这种方式,我提供了裁剪图像的功能。

直到现在我给了一个固定高度宽度的盒子来裁剪,但现在我需要提供一个功能,比如两根手指触摸,我的裁剪框会根据我的手指位置调整大小,就像苹果的 ScrollviewSuite 示例.我正在做以下事情:

 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{    
    UITouch *touch = [[event allTouches] anyObject];

    NSUInteger tapCount = [touch tapCount];
    UITapGestureRecognizer *twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTap:)];
    [twoFingerTap setNumberOfTouchesRequired:2];
    [newView addGestureRecognizer:twoFingerTap];

    CGPoint touchLocation = [touch locationInView:self.view];

    oldX = touchLocation.x;
    oldY = touchLocation.y;
}


- (void)handleTwoFingerTap:(UIGestureRecognizer *)gestureRecognizer 
{
    CGRect frame = newView.frame; \\newframe is the crop box
    frame.size.height += 100;
    newView.frame = frame;
}

但是通过这种方式,我只能以静态方式增加高度。我应该怎么做才能获取两个手指触摸和坐标?任何帮助都感激不尽。谢谢。

【问题讨论】:

    标签: iphone objective-c uiview uitouch


    【解决方案1】:

    handleTwoFingerTap 隐藏 self.view 和可见滚动视图..意味着您必须采用一个 uiview 和一个滚动视图 ..scrollview 进行缩放

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多