Я реализовал этот настраиваемый элемент управления в своем проекте: 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
Коды вы отправили в полном порядке. Он должен работать. Где код для текстового поля? Вы добавляете его через раскадровку, но где код для этого, чтобы подключить его и запустить событие жестов? –