简体   繁体   English

如何在uiscrollview上像uiimageview一样调整uiview的大小?

[英]How can I resize the uiview like that of uiimageview on uiscrollview?

I need to give functionality to user of cropping the image. 我需要为裁剪图像的用户提供功能。 I am displaying the uiimageview on a view and on that another view is being shown which is movable like a small box.on moving the box, it will give me the coordinates and as per that I will create a new image from the uiimageview. 我正在一个视图上显示uiimageview,并且正在显示另一个像小盒子一样可移动的视图。移动盒子时,它将提供我的坐标,并根据我将根据uiimageview创建一个新图像。 In such a way I am giving the functionality of a cropping Image. 我以这种方式提供了裁剪图像的功能。

Till now I was giving a fixed height width of the box to crop,But now I need to give a functionality like on 2 fingers touch,my crop box gets resized as per my fingers' position like that of ScrollviewSuite example of apple. 到现在为止,我给盒子的固定宽度是固定的,但是现在我需要提供2根手指触摸的功能,就像我的ScrollviewSuite例子一样,我的作物盒子会根据手指的位置调整大小。 I am doing following : 我正在执行以下操作:

 - (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;
}

But in this manner I am just able to increase the height in static manner. 但是以这种方式,我只能以静态方式增加高度。 What should i do to fetch two finger touches and coordinates? 我该怎么做以获取两个手指触摸和坐标? Any help will be much appreciated. 任何帮助都感激不尽。 Thank you. 谢谢。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在UIScrollView中移动UIImageView? - How Can I Move An UIImageView Around In A UIScrollView? UIScrollView-> UIView-> UIImageView - UIScrollView -> UIView ->UIImageView 如何以编程方式将UIView或UIImageView与“内部触摸”等事件相关联? - How can I programmatically link an UIView or UIImageView with an event like “touch up inside”? 我如何做链接到uiscrollview contentoffest的uiimageView缩放动画? - How i can do an uiimageView zoom animation linked to uiscrollview contentoffest? 如何在UIScrollView中找到UIImageView的缩放因子 - how can I find zooming factor of UIImageView inside UIScrollView 如何识别UIScrollView中的UIImageView子类上的轻击? - How can I recognize a tap on a UIImageView-subclass inside a UIScrollView? 调整imageview层的大小时,如何同时调整uiimageview的大小? - When I resize a layer of imageview, how can I resize the uiimageview at the same time? 如何在scrollViewDidZoom中动态调整contentInset?我最初在UIScrollview中设置了UIImageView的contentInset - How can I dynamically adjust contentInset in scrollViewDidZoom? I initially set contentInset of UIImageView in UIScrollview 隐藏某些视图时如何调整UIView宽度? - How can I resize UIView width when some view hidden? 如何检测用户是否只想滚动而不是在UIScrollView内点击UIImageView? - How can I detect if the user just wanted to scroll, and not tap on an UIImageView inside a UIScrollView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM