それで、これが私がやったことであり、それは非常にうまく機能します:
touchdragexit の UIButton が IBAction に割り当てられている
-(IBAction)dragPoint:(id)sender {
//Do Something Useful in here - I assign the value to an Array that I can recall when I touch up inside one of 16 buttons
//Now pass the button touch on as a touch up outside
[myButton addTarget:self action:@selector(dragBegan:withEvent:) forControlEvents: UIControlEventTouchUpOutside];
}
これで、dragBegan を次のように取得できます。
- (void)dragBegan:(UIControl *)c withEvent:ev {
UITouch *touch = [[ev allTouches] anyObject];
CGPoint touchPoint = [touch locationInView:self.view]; // Get location of the moment I release the touch (touch up outside)
//now some long convoluted code to give me the location of a row of 16 buttons, of which I would like to know which one I touched up inside
UIButton *posButton;
int pos;
if(628.00<(touchPoint.y) && (touchPoint.y)<664.00){
if ((39.00<touchPoint.x && touchPoint.x<91.00) || (92.00<touchPoint.x && touchPoint.x<144.00) || (145.00<touchPoint.x && touchPoint.x<197.00) || (198.00<touchPoint.x && touchPoint.x<250.00)||(264.00<(touchPoint.x) && touchPoint.x<314.00)||(317.00<(touchPoint.x) && touchPoint.x<367.00)||(370.00<(touchPoint.x) && touchPoint.x<420.00)||(423.00<(touchPoint.x) && touchPoint.x<473.00)||(488.00<(touchPoint.x) && touchPoint.x<538.00) || (541.00<(touchPoint.x) && touchPoint.x<591.00) || (594.00<(touchPoint.x) && touchPoint.x<644.00) || (647.00<(touchPoint.x) && touchPoint.x<697.00)||(712.00<(touchPoint.x) && touchPoint.x<762.00)||(765.00<(touchPoint.x) && touchPoint.x<815.00)||(818.00<(touchPoint.x) && touchPoint.x<868.00)||(871.00<(touchPoint.x) && touchPoint.x<921.00)){
if(39.00<(touchPoint.x) && touchPoint.x<91.00){
posButton = SeqA;
pos=0;
}
else if(92.00<(touchPoint.x) && touchPoint.x<144.00){
posButton = SeqB;
pos=1;
}
else if(145.00<(touchPoint.x) && touchPoint.x<197.00){
posButton = SeqC;
pos=2;
}
else if(198.00<(touchPoint.x) && touchPoint.x<250.00){
posButton = SeqD;
pos=3;
}
else if(264.00<(touchPoint.x) && touchPoint.x<314.00){
posButton = SeqE;
pos=4;
}
else if(317.00<(touchPoint.x) && touchPoint.x<367.00){
posButton = SeqF;
pos=5;
}
else if(370.00<(touchPoint.x) && touchPoint.x<420.00){
posButton = SeqG;
pos=6;
}
else if(423.00<(touchPoint.x) && touchPoint.x<473.00){
posButton = SeqH;
pos=7;
}
else if(488.00<(touchPoint.x) && touchPoint.x<538.00){
posButton = SeqI;
pos=8;
}
else if(541.00<(touchPoint.x) && touchPoint.x<591.00){
posButton = SeqJ;
pos=9;
}
else if(594.00<(touchPoint.x) && touchPoint.x<644.00){
posButton = SeqK;
pos=10;
}
else if(647.00<(touchPoint.x) && touchPoint.x<697.00){
posButton = SeqL;
pos=11;
}
else if(712.00<(touchPoint.x) && touchPoint.x<762.00){
posButton = SeqM;
pos=12;
}
else if(765.00<(touchPoint.x) && touchPoint.x<815.00){
posButton = SeqN;
pos=13;
}
else if(818.00<(touchPoint.x) && touchPoint.x<868.00){
posButton = SeqO;
pos=14;
}
else if(871.00<(touchPoint.x) && touchPoint.x<921.00){
posButton = SeqP;
pos=15;
}
内部でタッチアップしたボタンに応じて何かを実行します
私が行ったその他のこと - 元の UIButton のマスクを UIImageView として作成し、 touchdragoutside イベントで非表示にしないようにして (および上記の touchupinside で再入札した)、ドラッグできるボタンを作成しました。