2016-07-14 1 views
1

UITableViewCell 선택에서 didSelectRowAtIndexPath이 실행되므로 UIControlEventTouchUpInside과 같은 controlEvent가 있어야합니다 (예 :). didSelectRowAtIndexPath을 호출 할 때 어떤 controlEvent가 시작됩니까?
내가 묻는 이유는 내 UITableViewCell에 이벤트가 스 와이프 버튼이 didSelectRowAtIndexPath과 충돌하기 때문입니다. 그러나 iPhone의 기본 메일 응용 프로그램을 볼 때 매우 원활하게 작동합니다. 당신은 부드럽게 슬쩍 이벤트를 처리하는 다음과 같은 사항에 대해 대리자 메서드를 구현해야 할 필요가didSelectRowAtIndexPath의 controlEvent는 무엇입니까

+0

당신에게 모든 제스처가 처리하는 것을보기 위해 셀 (또는 contentView) 제스처 인식기를 조사해야합니다. 탭 동작을 찾으면이 동작을 사용하여 실행할 제스처를 제어 할 수 있습니다. 또한 실제로 작동하는 셀 스 와이프 기능을 추가 할 수있는 iOS 제공 방법이 있습니다. 너 그거 해봤 니? – keithbhunter

+1

didSelectRowAtIndexPath - 위임 메서드가 실행되는 곳 어디에서나 셀을 터치하면 detault에 의한 tableview의 위임 메서드입니다. 'controlEvent' - 셀 안에 UIElement (예 : UIButton, UIsegment, UISlider) 중 하나의 유형이 있습니다. 특정 요소 (전체 셀이 아닌)를 터치하면 액션이 실행됩니다. –

+0

@keithbhunter : 나는 두렵다. 그걸 알아도 될까요? – Nitish

답변

0

은 몇 가지 예 -

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { 

    UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Call" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ 

     // maybe show an action sheet with more options 

     // NSIndexPath *cellIndexPath = [self.tView indexPathForCell:cell]; 
     // UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Contact Info", @"Email Conversation",@"Clear Conversation", nil]; 
     // shareActionSheet.tag=indexPath.row; 
     // [shareActionSheet showInView:self.view]; 


     [self callButtonClicked:conObject.userName]; 

     //[cell hideUtilityButtonsAnimated:YES]; 

     [self.tView setEditing:NO]; 

    }]; 

    moreAction.backgroundColor=[UIColor colorWithRed:77.0/255.0 green:216.0/255.0 blue:101.0/255.0 alpha:1]; 

    // moreAction.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MobileRingIcon"]]; 

    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ 

     UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete"otherButtonTitles: nil]; 

     sheet.tag=indexPath.row; 

     [sheet showInView:self.view]; 

    }]; 

    [deleteAction setBackgroundColor:[UIColor redColor]]; 

    return @[deleteAction, moreAction]; 
} 

// From Master/Detail Xcode template 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 

    } else if (editingStyle == UITableViewCellEditingStyleInsert) { 

     // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. 
    } 
} 
-1

사용 commitEditingStyle

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 

을이 방법의주의입니다

관련 문제