私のiPhoneアプリでは、タッチイベントで遊びたいです。ここで私の要件は図に示すとおりです。
のイベントで作成Button 2
しています。ここにコードがありますtouch drag Exit
Button 1
-(IBAction)addView:(id)sender{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag=count;
count++;
[button addTarget:self action:@selector(imageTouch:withEvent:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(imageMoved:withEvent:) forControlEvents:UIControlEventTouchDragInside];
[button addTarget:self action:@selector(imageTouchCancel:withEvent:) forControlEvents:UIControlEventTouchUpInside];
button.frame=CGRectMake(shape1.frame.origin.x-30,shape1.frame.origin.y-40, 100, 100);
[button setImage:[UIImage imageNamed:imgname] forState:UIControlStateNormal];
[button addSubview:close];
[baseview addSubview:button];
}
ここでボタン 2 を正常に作成できますが、問題はボタン 2 をシングル タッチ イベントでドラッグして移動できないことです。つまり、ボタン 1 を外側にドラッグするとボタン 2 が作成されますが、ボタン 2 を移動するには指を使わなければなりません。画面から離れてボタン2を次にタッチすると、ボタン2を移動できます。
私の質問は、ボタン 2 を作成し、シングル タッチ サイクルで画面上を移動する方法ですか?