iPad アプリケーションで「ATrackThumb」と「BTrackThumb」という名前の 2 つの画像を使用して、ユーザーのタッチで移動します。この目的のためにいくつかの方法を使用しています。しかし、画像の動きは機能していません。メソッドは次のとおりです。
#pragma mark responding to touch events
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
for (UITouch *touch in touches) {
CGPoint t = [touch locationInView:touch.view];
if(t.x > (ATrackThumb.center.x-25) && t.x < (ATrackThumb.center.x+25) && t.y > (ATrackThumb.center.y-25) && t.y < (ATrackThumb.center.y+25)){
ASliderLastTouch = touch;
}
if(t.x>(BTrackThumb.center.x-25) && t.x < (BTrackThumb.center.x+25) && t.y > (BTrackThumb.center.y-25) && t.y < (BTrackThumb.center.y+25)){
BSliderLastTouch = touch;
}
}
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{
for (UITouch *touch in touches) {
CGPoint t = [touch locationInView:touch.view];
//Check Slider for Contact
if(touch==ASliderLastTouch){
if(t.x>205)
[ATrackThumb setCenter:CGPointMake(205,ATrackThumb.center.y)];
else if(t.x<24)
[ATrackThumb setCenter:CGPointMake(24,ATrackThumb.center.y)];
else
[ATrackThumb setCenter:CGPointMake(t.x,ATrackThumb.center.y)];
hourSlider.value=(ATrackThumb.center.x-24)/15;
[self updateHour];
}
if(touch==BSliderLastTouch){
if(t.x>205)
[BTrackThumb setCenter:CGPointMake(205,BTrackThumb.center.y)];
else if(t.x<24)
[BTrackThumb setCenter:CGPointMake(24,BTrackThumb.center.y)];
else
[BTrackThumb setCenter:CGPointMake(t.x,BTrackThumb.center.y)];
minutesSlider.value=(BTrackThumb.center.x-24)/3.0;
[self updateMinute];
}
}
}
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{
for (UITouch *touch in touches) {
if(touch==ASliderLastTouch)ASliderLastTouch=nil;
if(touch==BSliderLastTouch)BSliderLastTouch=nil;
}
}
問題はどこだ?