2013-03-11 6 views
1

재정렬 제어를 셀 왼쪽으로 이동하려고합니다. 사용자 지정 셀을 사용하고 있고 셀에 단추가 있습니다. 나는 실제로 다음 함수를 사용하여 왼쪽으로 이동할 수 있습니다. 그러나 내 오른쪽 버튼은 원래 기본 재정렬 제어가 있고 따라서 변환을 적용한 후에도 액세스 할 수없는 곳입니다. 뒤에 있지 않은 부분은 접근 가능합니다. 나는이 다음 링크 http://b2cloud.com.au/how-to-guides/reordering-a-uitableviewcell-from-any-touch-point순서 재정렬 제어를 왼쪽으로 이동

How to make reorder control of UITableViewCell in left side?

#pragma mark - 
#pragma mark rows reordering 

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    for(UIView* view in cell.subviews) 
    { 
     if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) 
     { 
      UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), 48)]; 
      [resizedGripView setBackgroundColor:[UIColor whiteColor]]; 
      [resizedGripView addSubview:view]; 
      [cell addSubview:resizedGripView]; 

      // Original transform 

      const CGAffineTransform transform = CGAffineTransformMakeTranslation(40 - cell.frame.size.width, 1); 


      [resizedGripView setTransform:transform]; 
      /*for(UIImageView* cellGrip in view.subviews) 
      { 
       if([cellGrip isKindOfClass:[UIImageView class]]) 
        [cellGrip setImage:nil]; 
      }*/ 
     } 
    } 
} 

을 사용했습니다 참고로

참조하십시오 http://i.stack.imgur.com/xBDLG.png

셀의 편집 버튼을 재정렬의 원래 위치에 액세스 할 수 없습니다이 이미지 제어. 나머지는 잘 작동합니다.

답변

1

나는 그것이

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell 
forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    for(UIView* view in cell.subviews) 
    { 
     if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) 
     { 

      UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), CGRectGetMaxY(view.frame))]; 
      [resizedGripView addSubview:view]; 
      [cell addSubview:resizedGripView]; 

      // Original transform 
      const CGAffineTransform transform = CGAffineTransformMakeTranslation(view.frame.size.width - cell.frame.size.width, 1); 
      // Move custom view so the grip's top left aligns with the cell's top left 

      [resizedGripView setTransform:transform]; 
     } 
    } 
} 
2

엑스 코드 8.2.1, 스위프트 3.X 도움이되기를 바랍니다,이 시도

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 
    cell.subviews.forEach() { 
     if ($0.description.range(of: "UITableViewCellReorderControl") != nil) { 
      let resizedGripView = UIView(frame: CGRect(x: 0, y: 0, width: $0.frame.maxX, height: $0.frame.maxY)) 
      resizedGripView.addSubview($0) 
      cell.addSubview(resizedGripView) 
      let transform = CGAffineTransform(translationX: $0.frame.size.width - cell.frame.size.width, y: 1) 
      resizedGripView.transform = transform 
     } 
    } 
}