Search code examples
iosxcodeuiscrollviewuiswipegesturerecognizer

UILabel in UIscrollView does not recognize UISwipegesture


code:
lblQuestion = [[UILabel alloc]initWithFrame:CGRectMake(23, intQuesPos, 280, 100)];
    lblQuestion.numberOfLines = 0;
    UISwipeGestureRecognizer *topGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeToptoBottom)];
    [topGesture setDirection:UISwipeGestureRecognizerDirectionDown];
    [lblQuestion addGestureRecognizer:topGesture];
    [scrollQuestion addSubview:lblQuestion];
    [vwQuestion addSubview:scrollQuestion];

I have UILabel in UIScrollView and I added UISwipegesture to UILabel. When I swipe down the UISCrollView only detected.

Any help will be appreciated.

Thanks in advance


Solution

  • Make userInteractionEnabled true for the lable

        lblQuestion.userInteractionEnabled=YES;