[memo] Objective-Cのタッチイベント

Categorie:{ Objective-C } Tag:{, , , } Comments:{ No Comments }
Posted:{ 2010.08.01 06:24:11 }

なんとなくカジッてるObjective-Cのタッチイベント、4種類。
よく使うのでメモ。(シングルタッチ)
タッチの座標をトレースするよ。
この辺は丸覚えなきゃね!

//------------------------------------------------------------
//
// タッチ開始
//
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
	CGPoint pos=[[touches anyObject] locationInView:self];
	NSLog(@"[BEGAN](x = %f , y = %f)",pos.x,pos.y);
}
//------------------------------------------------------------
//
// タッチムーブ
//
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
	//現在のタッチポイント
	CGPoint pos =[ [touches anyObject] locationInView:self];
	NSLog(@"[MOVE](x = %f , y = %f)",pos.x,pos.y);
}
//------------------------------------------------------------
//
// タッチ終了
//
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
	NSLog(@"[END]");
}
//------------------------------------------------------------
//
// タッチキャンセル
//
-(void)touchesCanceled:(NSSet *)touches withEvent:(UIEvent *)event{
	NSLog(@"[CANCELED]");
}

関連記事

Comment


レンタルサーバー豆知識