UIScrollViewに多くのUIImageViewが含まれています。UIImageをUIScrollViewから別のビューにドラッグする必要があります。しかし、私のコードはUIScrollViewでのみドラッグします。画像をscrollViewの外側にドラッグすることはできません。私を助けてください..私のコードは..
for (int i = 0; i < [myArray count]; i++) {
image = [[UIImageView alloc]initWithFrame:CGRectMake(0, y, 75, 30)];
image.userInteractionEnabled = YES;
image.backgroundColor = [UIColor blueColor];
UIPanGestureRecognizer *panRecg = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(labelDragged:)];
[image addGestureRecognizer:panRecg];
y=y+35;
[gScrollView addSubview:image];
}
-(void)labelDragged:(UIPanGestureRecognizer *)recognizer {
UIImageView *imageView = (UIImageView *)recognizer.view;
CGPoint newCenter = [recognizer translationInView:self.view];
if([recognizer state] == UIGestureRecognizerStateBegan) {
beginX = imageView.center.x;
beginY = imageView.center.y;
}
newCenter = CGPointMake(beginX + newCenter.x, beginY + newCenter.y);
[imageView setCenter:newCenter];
}