• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere

            路漫漫,長修遠,我們不能沒有錢
            隨筆 - 173, 文章 - 0, 評論 - 257, 引用 - 0
            數據加載中……

            為UITableView增加左右滑動事件

            UITableView 屏蔽了左右滑動事件.  通過重載的方式可以注入事件touch事件, 供開發者使用..

             1 //
             2 //  TouchTableView.h
             3 //  i2fBank4Iphone
             4 //
             5 //  Created by khan.lau on 13-1-8.
             6 //  Copyright (c) 2013年 khan.lau. All rights reserved.
             7 //
             8 
             9 #import <UIKit/UIKit.h>
            10 
            11 
            12 @protocol TouchTableViewDelegate <NSObject>
            13 @optional
            14 - (void)tableView:(UITableView *)tableView touchesBegin:(NSSet *)touches withEvent:(UIEvent *)event;
            15 - (void)tableView:(UITableView *)tableView touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
            16 - (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
            17 - (void)tableView:(UITableView *)tableView touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
            18 @end

             1 //
             2 //  TouchTableView.m
             3 //  i2fBank4Iphone
             4 //
             5 //  Created by khan.lau on 13-1-8.
             6 //  Copyright (c) 2013年 khan.lau. All rights reserved.
             7 //
             8 
             9 #import "TouchTableView.h"
            10 
            11 @implementation TouchTableView
            12 
            13 @synthesize touchDelegate = _touchDelegate;
            14 
            15 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
            16     [super touchesBegan:touches withEvent:event];
            17     
            18     if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
            19         [_touchDelegate respondsToSelector:@selector(tableView:touchesBegin:withEvent:)])
            20     {
            21         [_touchDelegate tableView:self touchesBegin:touches withEvent:event];
            22     }
            23 }
            24 
            25 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
            26     [super touchesCancelled:touches withEvent:event];
            27     
            28     if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
            29         [_touchDelegate respondsToSelector:@selector(tableView:touchesCancelled:withEvent:)])
            30     {
            31         [_touchDelegate tableView:self touchesCancelled:touches withEvent:event];
            32     }
            33 }
            34 
            35 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
            36     [super touchesEnded:touches withEvent:event];
            37     
            38     if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
            39         [_touchDelegate respondsToSelector:@selector(tableView:touchesEnded:withEvent:)])
            40     {
            41         [_touchDelegate tableView:self touchesEnded:touches withEvent:event];
            42     }
            43 }
            44 
            45 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
            46     [super touchesMoved:touches withEvent:event];
            47     
            48     if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
            49         [_touchDelegate respondsToSelector:@selector(tableView:touchesMoved:withEvent:)])
            50     {
            51         [_touchDelegate tableView:self touchesMoved:touches withEvent:event];
            52     }
            53 }
            54 
            55 @end
            56 


            調用方法 :
            1. 頭文件中加入delegate

            @interface MoneyViewCtl : UIViewController<UITableViewDataSource, UITableViewDelegate, SDWebDataDownloaderDelegate, EGORefreshTableHeaderDelegate, TouchTableViewDelegate>{

                

                IBOutlet UISegmentedControl *_sigTime;

                IBOutlet TouchTableView *_tableview;


            }

            @end



            2. .m文件中設置好delegate

            _tableview.touchDelegate = self;



            3. .m文件中實現如下事件


            #pragma mark - TouchTableViewDelegate lifecycle

            - (void)tableView:(UITableView *)tableView touchesBegin:(NSSet *)touches withEvent:(UIEvent *)event{

                NSLog(@"touchesBegin");

            }

            - (void)tableView:(UITableView *)tableView touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{

                NSLog(@"touchesCancelled");

            }


            - (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

                NSLog(@"touchesEnded");

            }

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

                NSLog(@"touchesMoved");

            }



            剩下的事情就可以自己發揮了


            posted on 2013-02-27 02:51 Khan 閱讀(5851) 評論(1)  編輯 收藏 引用 所屬分類: GCC/G++跨平臺開發

            評論

            # re: 為UITableView增加左右滑動事件  回復  更多評論   

            tableview沒有屏蔽右滑事件
            2015-02-28 09:10 | snowking
            国产精品免费看久久久香蕉| 亚洲AV伊人久久青青草原| 亚洲AV成人无码久久精品老人| 久久亚洲精品成人AV| 久久久久亚洲AV无码专区网站| 欧洲成人午夜精品无码区久久| 97久久精品无码一区二区天美| 国产69精品久久久久观看软件| 久久久久亚洲精品天堂久久久久久| 一级A毛片免费观看久久精品| 精品久久久久久无码中文字幕| 91视频国产91久久久| 久久精品这里只有精99品| 国产精品嫩草影院久久| 亚洲精品乱码久久久久66| 2020最新久久久视精品爱 | 日本三级久久网| 久久久久99精品成人片欧美| 欧美一区二区三区久久综| 久久精品亚洲福利| 91秦先生久久久久久久| 狠狠色婷婷久久一区二区三区| 国产精品岛国久久久久| 伊人色综合久久天天人守人婷 | 国内精品久久久久久久久电影网 | 久久久久久久久66精品片| 久久国产精品免费| 国内精品久久久久影院免费| 久久综合综合久久97色| 久久青青草原精品国产| 久久久久亚洲AV无码专区首JN| 亚洲中文久久精品无码ww16| 亚洲精品午夜国产va久久| 色偷偷91久久综合噜噜噜噜| 很黄很污的网站久久mimi色| 国产叼嘿久久精品久久| 丰满少妇人妻久久久久久4| 国产精品视频久久久| 天天爽天天爽天天片a久久网| 久久精品国产福利国产秒| 久久99国产精品99久久|