프로젝트에서이 사용자 지정 컨트롤을 구현했습니다. Github page이 컨트롤은 사용하려는 기능을 삭제/완료하기 위해 스 와이프와 같은 사서함을 추가합니다.UITextfield가 스 와이프 동작을 방해합니다.
스토리 보드를 통해 셀에 UITextField를 추가하는 경우에만이 문제가 발생했습니다. 하나를 추가하면 셀이 제스처를 인식하지 못하며 UITextField와 상호 작용할 수있게됩니다.
누구든지이 문제에 대한 해결책이 있습니까?
편집 : 다음은 TableViewCell의 초기화 메소드입니다. 죄송합니다.
- (void)initializer
{
_mode = MCSwipeTableViewCellModeSwitch;
_colorIndicatorView = [[UIView alloc] initWithFrame:self.bounds];
[_colorIndicatorView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[_colorIndicatorView setBackgroundColor:[UIColor clearColor]];
[self insertSubview:_colorIndicatorView belowSubview:self.contentView];
_slidingImageView = [[UIImageView alloc] init];
[_slidingImageView setContentMode:UIViewContentModeCenter];
[_colorIndicatorView addSubview:_slidingImageView];
_panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGestureRecognizer:)];
[self addGestureRecognizer:_panGestureRecognizer];
[_panGestureRecognizer setDelegate:self];
}
및
- (void)handlePanGestureRecognizer:(UIPanGestureRecognizer *)gesture
{
UIGestureRecognizerState state = [gesture state];
CGPoint translation = [gesture translationInView:self];
CGPoint velocity = [gesture velocityInView:self];
CGFloat percentage = [self percentageWithOffset:CGRectGetMinX(self.contentView.frame) relativeToWidth:CGRectGetWidth(self.bounds)];
NSTimeInterval animationDuration = [self animationDurationWithVelocity:velocity];
_direction = [self directionWithPercentage:percentage];
if (state == UIGestureRecognizerStateBegan)
{
}
else if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStateChanged)
{
CGPoint center = {self.contentView.center.x + translation.x, self.contentView.center.y};
[self.contentView setCenter:center];
[self animateWithOffset:CGRectGetMinX(self.contentView.frame)];
[gesture setTranslation:CGPointZero inView:self];
}
else if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled)
{
_currentImageName = [self imageNameWithPercentage:percentage];
_currentPercentage = percentage;
MCSwipeTableViewCellState state = [self stateWithPercentage:percentage];
if (_mode == MCSwipeTableViewCellModeExit && _direction != MCSwipeTableViewCellDirectionCenter && [self validateState:state])
[self moveWithDuration:animationDuration andDirection:_direction];
else
[self bounceToOriginWithDirection:_direction];
}
}
문제가있는 코드를 게시하거나 사용중인 컨트롤을 만든 사람에게 돌아가서 도움을 요청하십시오. 코드에 문제가 있거나 도움을받을 수있는 경우 도움을 드리려고합니다. –
죄송합니다. 나는 코드를 추가했다. – cherbear
게시 한 코드는 완벽합니다. 그것은 작동해야합니다. 텍스트 필드의 코드는 어디에 있습니까? 스토리 보드를 통해 추가하고 있지만 코드를 연결하고 제스처 이벤트를 시작하기위한 코드는 어디에 있습니까? –