2011-07-23 5 views
1

私のアプリでは、画面上で円をドラッグすることができます。私は、これを実装するために取るべき標準的なステップがあるかどうか、特にビューの正しい領域を汚れているとマークすることに関しては疑問に思っています。私は現在、次のことをやっている:iOS:drawRect:draggableオブジェクトを実装する際の標準規則

//Get initial touch point and draw a circle there. Use touch point and size of circle to pass the mark the appropriate CGRect as dirty so that it gets redrawn 
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 

//Get new touchpoint and draw a circle there. Use the union of the previous CGRect and the new one (based on the touch point and circle size) to tell drawRect: what area of the screen to redraw. 
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

は、これは正しいように見える場合、または私がやるべきいくつかの他の基本的な部分はありますか?

+0

コードを追加しましたか?あるいは、あなたはそれらの方法を実装しているということだけですか? – ThomasW

+0

私は実装の詳細を心配していないので、コードを追加するつもりはありませんでした。もちろん – maxedison

答えて

1

あなたのビューが円を描いていると仮定すると、あなたがやっていることはうまくいくはずです。 [self setNeedsDisplayInRect: circleRect]を使用して、円の以前の位置と新しい位置をダーティーとしてマークしてください。

+0

。前のステップで確認を探していただけだった。どうも。 – maxedison

関連する問題