2012-04-10 2 views
0

iOS5 사용. 사용자 정의 정적 셀 내부로 UIButton 객체를 드래그했습니다. 동적 속성을 사용하지 않으므로 데이터 소스 템플릿을 사용하지 않습니다. 문제는 셀 안의 UIButton을 눌렀을 때 어떤 이벤트도 트리거 할 수 없다는 것입니다. 내 테이블 뷰 컨트롤러에 folioing 코드를 실행하고 있습니다 :사용자 정의 고정 셀 내에서 UIButton을 누르면 동작하지 않습니다.

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    NSIndexPath *myIP = [NSIndexPath indexPathForRow:1 inSection:1]; 
    UITableViewCell *cell = [medicareTableView cellForRowAtIndexPath:myIP]; 
    UIButton *stepNumberOfChildren = (UIButton *)[cell viewWithTag:222]; 

    [stepNumberOfChildren addTarget:self action:@selector(dontTouchMe:) forControlEvents:UIControlEventTouchUpInside]; 

} 
- (void)dontTouchMe:(id)sender { 
    NSLog(@"Touched Button %i",((UIButton *)sender).tag); 
} 

이 앱을 눌러있는 UIButton을 실행하고 아무것도 기록하지 않습니다 ... 내가 잘못 뭐하는 거지?

+0

'[NSIndexPath indexPathForRow : 1 inSection : 1]; –

+0

viewDidLoad에서'cellForRowAtIndexPath'를 사용하여 tableviewcell을 얻지 못할 수도 있습니다. – DivineDesert

답변

2

dontTouchMe 기능에 콘센트를 연결합니다 (TouchUpInside) 당신은 행에있는 셀에 대상을 추가 할 희망

+0

감사합니다! 내 콘센트가 연결되지 않았어. 어떤 이유로 NSLog가 시작되지 않지만 다른 호출을 호출 할 수 있기 때문에 버튼 이벤트가 실제로 푸시됩니다. – Pupillam

+1

답변을 클릭하십시오. 감사하겠습니다. – Satish

0

= 1 개, 섹션 1

그래서 코드는 다음과 = 같이

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(indexpath.row==1&&indexpath.section==1) 
    { 
    //add the button target 
    } 
} 
관련 문제