하나의 응용 프로그램을 개발했습니다. 해당 응용 프로그램에서 한 가지 문제가 있습니다.
scrollview를 tableview 셀에 추가하려고합니다. 아래 코드를 사용하여 tableview 셀을 만들었습니다.Scrollview가 여러 테이블 뷰 셀에 표시됩니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; ExistingCasesCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[ExistingCasesCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; //Adding SwipeGestures to a cell UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; [cell addGestureRecognizer:swipeRight]; swipeRight=nil; UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; [cell addGestureRecognizer:swipeLeft]; swipeLeft=nil; } cell.buttonEdit.tag=tagForButtonCustomCell*indexPath.row+0; [cell.buttonEdit addTarget:self action:@selector(btnOptionsClicked:) forControlEvents:UIControlEventTouchUpInside]; cell.buttonShare.tag=tagForButtonCustomCell*indexPath.row+1; [cell.buttonShare addTarget:self action:@selector(btnOptionsClicked:) forControlEvents:UIControlEventTouchUpInside]; cell.buttonAdd.tag=tagForButtonCustomCell*indexPath.row+2; [cell.buttonAdd addTarget:self action:@selector(btnOptionsClicked:) forControlEvents:UIControlEventTouchUpInside]; cell.buttonDelete.tag=tagForButtonCustomCell*indexPath.row+3; [cell.buttonDelete addTarget:self action:@selector(btnOptionsClicked:) forControlEvents:UIControlEventTouchUpInside]; Item *itemObject = [arrSavedDocuments objectAtIndex:indexPath.row]; UILabel *labelDocumentName=(UILabel *)[cell.contentView viewWithTag:tagForLabelDocument]; labelDocumentName.text=itemObject.itemTypeName; UILabel *labelNumOfPages=(UILabel *)[cell.contentView viewWithTag:tagForLabelNumberOfPages]; labelNumOfPages.text=[NSString stringWithFormat:@"%d", [[itemObject.itemToPage allObjects]count]]; UILabel *labelDate=(UILabel *)[cell.contentView viewWithTag:tagForLabelDate]; labelDate.text=[self parseDateString:itemObject.itemCreatedTimeStamp]; return cell; }
여기 ExistingCasesCustomCell
은 내 사용자 정의 셀 클래스입니다. ExistingCasesCustomCell
의 init 메소드에서 서브 뷰가있는 scrollview를 4 개의 버튼 (buttonEdit, buttonShare, buttonAdd 및 buttonDelete)으로 추가했습니다. 처음에는 scrollview가 숨겨진 위치에 있습니다.
내 요구 사항은 스크롤보기에 표시되어야하는 셀을 스 와이프 할 때마다입니다. 사용자가 셀을 스 와이프 할 때마다 스크롤보기가 나타납니다.
하지만 내 문제는 내가 스크롤보기가 다른 셀에도 표시되는 tableview를 스크롤 할 때마다입니다. 이 문제를 어떻게 해결할 수 있습니까? 사전에
감사합니다,
Rambabu N
값이 NO 인 ExistingCasesCustomCell 클래스에서 Bool 변수를 만듭니다. 스 와이프하면 Yes로 변경하십시오. 이 cell.yourVar가 NO이면 cellForRowAtIndexPath()에 체크를하고 그렇지 않으면 스크롤 뷰를 숨 깁니다. scrollView를 표시합니다. – Yogendra