사용자 정의 UITableview
을 섹션으로 나누어서 UISwipeGestureRecognizer
을 구현했습니다. 표보기 셀을 스 와이프하면 UIButton
이 표시됩니다. 지금 직면하고있는 문제는 첫 번째 테이블보기 셀을 스 와이프 할 때 연속 섹션의 다른 셀도 스 와이프 제스처를 인식한다는 것입니다. 다른 섹션의 다른 셀을 스 와이프하지 않고 특정 섹션의 셀을 스 와이프하는 방법을 찾을 수 없습니다.섹션의 특정 행에 대해 tableviewcell을 스 와이프하는 방법
방금 스 와이프하고 싶지만 삭제/삽입하거나 체크 표시를 추가하고 싶지는 않습니다.
UPDATE는 .... 이건 내 MainViewController.m에서의 TableView = customTableView
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.symptomCellImageView.contentMode=UIViewContentModeScaleToFill;
swipeButton = [[UIButton alloc]init];
swipeButton .frame = CGRectMake(220.0, 8.0, 30.0, 30.0);
swipeButton .hidden = NO;
}
내 customCell.m 입니다
-(void)viewDidLoad
{
symptomSwipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandleLeft)];
symptomSwipeLeft .numberOfTouchesRequired = 1;
symptomSwipeLeft .direction = UISwipeGestureRecognizerDirectionLeft;
[customTableView addGestureRecognizer:symptomSwipeLeft];
[self addGestureRecognizer:symptomSwipeRight];
symptomSwipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandleRight)];
symptomSwipeRight.numberOfTouchesRequired = 1;
symptomSwipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[customTableView addGestureRecognizer:symptomSwipeRight];
[self addGestureRecognizer:symptomSwipeRight];
}
- (void)swipeHandleLeft:(UISwipeGestureRecognizer *)aSwipeGestureRecognizer
{
CGPoint location = [aSwipeGestureRecognizer locationInView:customTableView ];
NSIndexPath * indexPath = [customTableView indexPathForRowAtPoint:location];
if(indexPath)
{
UITableViewCell * cell = (UITableViewCell *)[customTableView cellForRowAtIndexPath:indexPath];
[cell.swipeButton addTarget:self action:@selector(secondPageButton:) forControlEvents:UIControlEventTouchUpInside];
}
}
- (void)swipeHandleRight:(UISwipeGestureRecognizer *)aSwipeGestureRecognizer
{
CGPoint location = [aSwipeGestureRecognizer locationInView:customTableView ];
NSIndexPath * indexPath = [customTableViewindexPathForRowAtPoint:location];
if(indexPath)
{
UITableViewCell * cell = (UITableViewCell *)[customTableView cellForRowAtIndexPath:indexPath];
[cell.swipeButton addTarget:self action:@selector(secondPageButton:) forControlEvents:UIControlEventTouchUpInside];
}
}
.. [셀을 호출하지 않아야합니다.swipeButton addTarget을 : 자기 행동 : @selector (intoView : forControlEvents는 : UIControlEventTouchUpInside] cellForRowAtIndexPath에 와 태그가 cellForRowAtIndexPath에서 수행해야 바로 – raptor
내 코드는'UISwipeGestureRecognizer'을 가지고 당신에게 사용자가 보내 주시면됩니다 정확한 셀을 줄 것이다 . 거기에서 원하는 방식으로 호출 할 수 있습니다. 따라서 스 와이프 버튼을 나타나게하려면'cell.swipeButton.hidden =! cell.swipeButton.hidden'을 호출하면됩니다 (숨겨진 버튼은 보이지 않는 경우 숨김 버튼이됩니다). 사용자 정의 셀 메서드를 호출하여 단추를 애니메이션으로 만들 수도 있습니다! '.tag' 속성은 전혀 필요 없습니다! – msgambel
감사합니다 :) ... 나는 그것을 조사 할 것입니다. 첫 번째 섹션에서 셀을 스 와이프하면 다른 섹션에서 셀을 스 와이프하지 않습니다. – raptor