0
私はiPadアプリのために現時点でインタラクティブなアナグラム機能を構築していますが、選択した項目をスムーズにフォローするためにtouchmoveイベントを使用しようとしていますが、理由。iPhoneのドラッグアンドドロップの奇妙なジャンプムーブ
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
NSString *touchClass = [NSString stringWithFormat:@"%@",[[touch view] class]];
if ([touchClass isEqualToString:[NSString stringWithFormat:@"%@",[AnagramLetter class]]]) {
NSLog(@"start moving");
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSString *touchClass = [NSString stringWithFormat:@"%@",[[touch view] class]];
CGPoint location = [touch locationInView:touch.view];
if ([touchClass isEqualToString:[NSString stringWithFormat:@"%@",[AnagramLetter class]]]) {
NSLog(@"touch view centre (x,y) - (%f,%f)",touch.view.center.x,touch.view.center.y);
NSLog(@"location (x,y) - (%f,%f)",location.x,location.y);
touch.view.center = location;
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
NSString *touchClass = [NSString stringWithFormat:@"%@",[[touch view] class]];
if ([touchClass isEqualToString:[NSString stringWithFormat:@"%@",[AnagramLetter class]]]){
NSLog(@"Now stop moving!");
}
}
上記は私の3タッチの方法であり、正常に動作するはずです。 touchesMovedメソッドでは、移動対象のオブジェクトが特定のクラス(同じプロジェクトに対して作成したカスタムクラス)かどうかを確認しています。なぜこのようなことが起こっているのか誰にも考えていますか?それはシミュレータのカーソルに追従していますが、カーソルの後にくる前に下隅にスナップしているように見えるので、基本的に画面全体にジャンプしています。
アイデア?
を同じ変位を適用することができtouchesMoved方法で
は、感謝を御馳走を働きました!そのコードはすべてのプロジェクトでリサイクルされます:) –