Получение касаний Начало: на UIViewController - Цель C - PullRequest
0 голосов
/ 16 марта 2019

Я добавил UITableView как подпредставление в моем UITableView.У меня есть тревожные «проходящие» прикосновения к моему UITableView (подпредставлению) к представлению моего UIViewController (где мой touchesBegan: метод работает, как и ожидалось).

Я пробовал:

  • Создание подкласса для моего UITableView и передача штрихов Bean: оттуда к суперпредставлению
  • pointInside: в суперпредставлении
  • hitTest: в подклассовом табличном представлении

Также: отключение userInteraction на моем tableView работает, но, конечно, я все еще хочу сохранить функциональность cellDidSelectRow ...

Реализация моего кода в ViewController:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesBegan popup");
    if (!self.draggable) {
        //[super touchesBegan:touches withEvent:event];
        return;
    }

    UITouch *touch = [touches anyObject];
    if (!_moving) {
    //(touch.view == self || touch.view.superview == self) &&
        _moving = YES;
        _movingStartY = [touch locationInView:self.view].y;
        NSLog(@"moving popup");
    }

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

    if (!self.draggable) {
        //[super touchesMoved:touches withEvent:event];
        return;
    }

    if (_moving) {
        NSLog(@"touchesMoved popup");
        UITouch *touch = [touches anyObject];
        float offset = [touch locationInView:self.view].y - _movingStartY;
        if ([self.touchEventDelegate respondsToSelector:@selector(popupNavigationBar:touchDidMoveWithOffset:)]) {
            [self.touchEventDelegate popupNavigationBar:self touchDidMoveWithOffset:offset];
        }
    }
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (!self.draggable) {
        //[super touchesCancelled:touches withEvent:event];
        return;
    }

    if (_moving) {
        UITouch *touch = [touches anyObject];
        float offset = [touch locationInView:self.view].y - _movingStartY;
        [self movingDidEndWithOffset:offset];
    }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (!self.draggable) {
        //[self touchesEnded:touches withEvent:event];
        return;
    }

    if (_moving) {
        UITouch *touch = [touches anyObject];
        float offset = [touch locationInView:self.view].y - _movingStartY;
        [self movingDidEndWithOffset:offset];
    }
}

- (void)movingDidEndWithOffset:(float)offset
{
    _moving = NO;
    if ([self.touchEventDelegate respondsToSelector:@selector(popupNavigationBar:touchDidEndWithOffset:)]) {
        [self.touchEventDelegate popupNavigationBar:self touchDidEndWithOffset:offset];
    }
}

Как мне это сделать?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...