2012-03-07 1 views
1

내 UIViewController에는 다른 UIView가 있고 그 중 일부는 내 사용자 정의 UIViews입니다. 어느 UIView가 만져 졌는지, 내 사용자 정의 여부를 아는 방법 ??iPhone : 어떤 객체를 만졌는지 확인하는 방법

UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; 
[view addGestureRecognizer:recognizer]; 

UITapGestureRecognizer * recognizerCustom = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapCustom:)]; 
[customView addGestureRecognizer:recognizer]; 

당신이 handleTap 때 알고이 방법 :

+1

: http://stackoverflow.com/questions/2793242/detect-if-certain-uiview-was 기타 - uiviews 사이에 - – Oritm

+0

예, 감사합니다 .... – Jim

+0

시도 isKindOfClass 메서드 – HarshIT

답변

2

각보기에 태그를 설정할 수 있습니다.

view1.tag = y; 
UITapGestureRecognizer *tapGesture = 
    [[UITapGestureRecognizer alloc] initWithTarget:self 
              action:@selector(singleTapGestureCaptured:)]; 
tapGesture.numberOfTapsRequired = 1; 
[view1 addGestureRecognizer:tapGesture]; 

singleTapGestureCaptured 방법 : 당신은 여기에서 답을 찾을 수 있습니다

- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture 
{ 
    [[gesture view] tag]; 
    NSLog(@"tap captured for view :%d", [[gesture view] tag]); 
} 
1

당신은 당신의이 같은 전망 제스처 인식기를 연결해야 두 개의 UIGestureRecognizers을 만들 수있는 방법이 감동 된 일반보기라고하고 때 handleTapCustom : 사용자 정의보기라는 호출이 호출되었습니다.

관련 문제