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을 실행하고 아무것도 기록하지 않습니다 ... 내가 잘못 뭐하는 거지?
'[NSIndexPath indexPathForRow : 1 inSection : 1]; –
viewDidLoad에서'cellForRowAtIndexPath'를 사용하여 tableviewcell을 얻지 못할 수도 있습니다. – DivineDesert