2012-02-05 3 views
3

나는 사용자 정의 셀이있는 UITableView이 있습니다. 이 사용자 지정 셀에서이 테이블의 편집 모드를 트리거하는 UILongPressGestureRecognizer을 정의했습니다. 누군가가 1.5 초 동안 셀을 누르고 있으면 편집 모드가됩니다.트리거 setEditing : 애니메이션 : 편집 버튼을 사용하지 않고

- (void)startEditMode:(UISwipeGestureRecognizer *)recognizer { 

    if (self.allowEdit) { 
     UITableView *table = (UITableView *)self.superview; 
     [table setEditing:YES animated:YES]; 
    } 

} 

을하지만 내가 원하는 것은 내가/보여이 경우 몇 가지 추가 버튼을 숨길 필요가 있기 때문에 테이블이 편집 모드로 전환 할 때 감지 할 수 있습니다 : 트리거

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startEditMode:)]; 

. 하지만 내의 ViewController에서 어떤 이유로이 실행되지 않습니다 :

- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 
    NSLog(@"SET EDITING"); 
    [super setEditing:editing animated:animated]; 
} 

어떤 제안 왜? 이것은 UINavigationController에서 기본적으로 제공되는 적절한 편집 단추를 사용할 때 호출되는 것입니까?

또는 UITableView가 편집 모드로 전환되는 것을 어떻게 감지합니까?

답변

4

당신은 (setEditing) 메시지를 테이블 뷰로 보냈습니다. 뷰 컨트롤러 (아마도 UITableViewController 서브 클래스입니까?)로 보내야합니다. 그런 다음 테이블보기를 처리합니다.

1

그래, 다른 사람이 같은 문제로이 스레드에 들어갈 경우, 내가 어떻게 해결했는지 보여 줄 것입니다. 내 사용자 지정 UITableViewCell에서

지금은이 방법이 있습니다

- (void)startEditMode:(UISwipeGestureRecognizer *)recognizer { 

    if (self.allowEdit) { 
     UITableView *table = (UITableView *)self.superview; 
     UITableViewController *control = (UITableViewController *)table.dataSource; 
     [control setEditing:YES animated:YES]; 
    } 

}