我想在UIImageView上應用手勢時,IAM給 姿勢縮放旋轉和圖像移動的ImageView工作的行動。所以我可以看到圖像旋轉和縮放,並從一個點移動到另一個點。GestureRecognizer問題與兩個視圖UIView和UIImageView
當我縮放圖像和縮放級別最低,並在觸及UIView這是UIImageView的超類,也給予了手勢動作。如何限制只需在UIImageView上工作而不在UIView上的手勢。並試圖將其限制在UIVIew中Imageview不需要在視圖之外。
-(void)InitGestures{
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
tapRecognizer.numberOfTouchesRequired = 1;
templatePhotoPlaceholderView=[[UIView alloc]init];
templatePhotoPlaceholderView.clipsToBounds = YES;
//templatephotoplaceholder frame setting
[self templatePhotoPlaceholderFrameSetting];
templatePhotoPlaceholderView.backgroundColor=[UIColor colorWithRed:0.8823 green:0.8823 blue:0.8823 alpha:1];
[self photoView:templatePhotoPlaceholderView];
tapRecognizer.view.frame=templatePhotoPlaceholderView.frame;
[self photoButtonPlaceHolder:templatePhotoPlaceholderView];
[selectedTemplateImage addSubview:templatePhotoPlaceholderView];
[templatePhotoPlaceholderView addGestureRecognizer:tapRecognizer];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelegate:self];
[templatePhotoPlaceholderView addGestureRecognizer:panRecognizer];
//[panRecognizer release];
UIPinchGestureRecognizer *pinchRecognizer = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)] autorelease];
[pinchRecognizer setDelegate:self];
[self.view addGestureRecognizer:pinchRecognizer];
//[pinchRecognizer release];
[self.view addSubview:templatePhotoPlaceholderView];
[tapRecognizer release];
}
-(void)move:(UIPanGestureRecognizer *)gestureRecognizer
{
CGPoint translatedPoint = [gestureRecognizer translationInView:templatePhotoPlaceholderView];
if([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
_firstX = [imageview center].x;
_firstY = [imageview center].y;
}
translatedPoint = CGPointMake(_firstX+translatedPoint.x, _firstY+translatedPoint.y);
[imageview setCenter:translatedPoint];
}
任何人都知道如何限制運動圖像在指定的範圍內。 – user905582
只是限制你的超級景觀的框架 – kiran