3 개의 항목이있는 테이블보기가 있는데 그 중 하나는 단추 뒤에 있습니다. 버튼이 선택되면, 그 버튼을 숨기고 그 뒤에있는 아이템을 드러내고 싶습니다. 테이블 뷰 셀을 사용하여 테이블 행을 표시하고 있습니다. 숨길 버튼을 하나 선택하면 테이블을 스크롤하면 더 많은 버튼이 숨겨집니다. 버튼을 숨기면 현재보기의 표시 가능한 행 내의 일부 위치를 기반으로 버튼이 숨겨져있는 것처럼 보입니다. 특정 행의 버튼을 숨기려고합니다.테이블 뷰 행의 버튼을 어떻게 든 인덱싱 할 수 있습니까?
버튼을 숨기려면 코드를 누를 때마다 NSLog에 쓸 수 있으며 한 번만 표시되지만 테이블을 스크롤하면 볼 수있는 다른 행에 버튼의 숨겨진 속성이 적용됩니다. 행 53의 버튼을 선택하면 행 53의 버튼 만 숨기고 120 행 테이블의 다른 행의 버튼은 숨기지 마십시오.
내가 한 일을 해 본 사람이 있습니까? 내가 무슨 일이 일어나고 있는지 알아낼 수있는 도움을 주시면 감사하겠습니다. 감사.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *ElementCellIdentifier = @"ElementCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ElementCellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ElementRowCell"
owner:self options:nil];
if ([nib count] > 0) {
cell = self.tvCell;
} else {
NSLog(@"failed to load ElementRowCell nib file!");
}
}
NSUInteger row = [indexPath row];
UILabel *atomic_number = (UILabel *)[cell.contentView viewWithTag:1];
atomic_number.text = [NSString stringWithFormat:@"%d",elements_table[row].atomic_number];
UILabel *element_name = (UILabel *)[cell.contentView viewWithTag:2];
element_name.text = [NSString stringWithCString:elements_table[row].element_name];
UILabel *element_symbol = (UILabel *)[cell.contentView viewWithTag:3];
element_symbol.text = [NSString stringWithCString:elements_table[row].element_symbol];
return cell;
}
- (IBAction)buttonPressed:(id)sender {
NSLog(@"Getting to buttonPressed from row button");
UIButton *pressedButton = (UIButton *)sender;
NSIndexPath *indexPath = [self.mainTableView indexPathForCell: (UITableViewCell *)[sender superview]];
pressedButton.hidden = TRUE;
}
회원님이이 결과를 얻고있는 이유를 확인합니다. 'tableView : cellForRowAtIndexPath :'와 버튼을 숨기는 액션 메소드를 게시하십시오. – NJones
저는이 포럼을 처음 사용합니다. 이 코멘트 란에 허용되는 문자 수를 초과합니다. 코드를 게시하려면 어떻게해야합니까? – Rick
질문을 편집하여 코드를 추가하십시오. 질문의 텍스트 바로 아래에 질문 태그가 있습니다. 바로 아래에 편집 링크가 표시되어야합니다. – NJones