画像のみのアプリを作ろうとしています。次に、ユーザーが画像に触れるとコピーが作成され、画像を別の場所に移動してそこにドロップできます。
これは私が作成したコードです:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
CGPoint touch_point = [myTouch locationInView:view1];
if ([view1 pointInside:touch_point withEvent:event]) {
UIImageView *view= [UIImageView alloc];
[self.view addSubview:view];
[view release];
view.userInteractionEnabled=YES;
view.frame = CGRectMake(0, 0, 100.0, 100.0);
view.center = [myTouch locationInView:self.view];
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
CGPoint touch_point = [myTouch locationInView:view1];
if ([view1 pointInside:touch_point withEvent:event]) {
view.image=view1.image;
}
}
私の問題は、 で作成された *view にアクセスできず、touchesBegan
で使用できないことですtouchesMoved
。この画像ビューを公開する方法を知っている人はいますか?