zoukankan      html  css  js  c++  java
  • iOS UITableView UIScrollView 的支持触摸事件

    在使用了 UITableView 或UIScrollView的controller 里无法响应触摸事件touch事件, 自定义tableView、scrollView

    #import <UIKit/UIKit.h>
    
    @interface touchScrollView : UIScrollView
    
    @end
    
    #import "touchScrollView.h"
    
    @implementation touchScrollView
    
    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code
        }
        return self;
    }
    
    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        [super touchesBegan:touches withEvent:event];
        if ( !self.dragging )
        {
            [[self nextResponder] touchesBegan:touches withEvent:event];
        }
    }
    
    -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
        [super touchesEnded:touches withEvent:event];
        if ( !self.dragging )
        {
            [[self nextResponder] touchesEnded:touches withEvent:event];
        }
    }
    
    -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [super touchesEnded:touches withEvent:event];
        if(!self.dragging)
        {
            [[self nextResponder] touchesCancelled:touches withEvent:event];
        }
    }
    
    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [super touchesMoved:touches withEvent:event];
        if(!self.dragging)
        {
            [[self nextResponder] touchesMoved:touches withEvent:event];
        }
    }
    
  • 相关阅读:
    二逼平衡树(树套树)
    NOI2010 超级钢琴
    SDOI2011 消耗战
    HNOI2013 游走
    [SDOI2010]外星千足虫
    [UVA 11374]Airport Express
    [Luogu P1354]房间最短路问题
    [Luogu P2296][NOIP 2014]寻找道路
    高精度算法
    洛谷红名+AC150祭
  • 原文地址:https://www.cnblogs.com/levy/p/4727394.html
Copyright © 2011-2022 走看看