国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

ios觸屏事件指南

2020-07-26 03:35:40
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

//在一個函數里面(初始化等)里面添加要識別觸摸事件的范圍
    infoView=[[UIView alloc] initWithFrame:CGRectMake(20, 100,220, 280)];//范圍,出了這個范圍就檢測不到觸摸了
    infoView.backgroundColor=[UIColor blueColor];
    infoView.alpha=0.6;
    [self.view addSubview:infoView];
    /******************監視手勢控制*****************///有上下左右,我只用到了左右,上下注掉了。
    UISwipeGestureRecognizer *recognizer;
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [infoView addGestureRecognizer:recognizer];
//    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
//    [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
//    [self.view addGestureRecognizer:recognizer];
//    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
//    [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
//    [self.view addGestureRecognizer:recognizer];
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [infoView addGestureRecognizer:recognizer];
//觸摸事件 的實現函數
//滑動事件1
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
    //如果往左滑
    if(recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
        NSLog(@"****************向左滑****************");
    }
    //如果往右滑
    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
        NSLog(@"****************向右滑****************");      
    }
   if (recognizer.direction==UISwipeGestureRecognizerDirectionDown){
       NSLog(@"****************向下滑****************");
    }
    if (recognizer.direction==UISwipeGestureRecognizerDirectionUp){
      NSLog(@"****************向上滑****************");
   }
}

方法二:

復制代碼 代碼如下:

GSEventRecord header;    
GSHardwareKeyInfo key = {0,0,0,0,1,{'a'},1,{'a'},0,0,0,0};    
memset(&header, 0, sizeof(header));    
header.type = kGSEventKeyDown;    
header.infoSize = sizeof(GSHardwareKeyInfo);    
header.timestamp = mach_absolute_time();    
struct    
{    
    GSEventRecord header1;    
    GSHardwareKeyInfo key1;    
}fuck = {header, key};    
GSSendEvent(&fuck, GSGetPurpleApplicationPort());   
    GSEventRecord header; 
    GSHardwareKeyInfo key = {0,0,0,0,1,{'a'},1,{'a'},0,0,0,0}; 
    memset(&header, 0, sizeof(header)); 
    header.type = kGSEventKeyDown; 
    header.infoSize = sizeof(GSHardwareKeyInfo); 
    header.timestamp = mach_absolute_time(); 
    struct 
    { 
        GSEventRecord header1; 
        GSHardwareKeyInfo key1; 
    }fuck = {header, key}; 
    GSSendEvent(&fuck, GSGetPurpleApplicationPort());

以上所述就是本文的全部內容了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 天水市| 利津县| 湖州市| 浦县| 元氏县| 石狮市| 双流县| 泸定县| 沂南县| 瓦房店市| 榆社县| 东兴市| 新平| 金湖县| 清镇市| 库尔勒市| 广饶县| 巩义市| 聂荣县| 太仆寺旗| 巫溪县| 平舆县| 泸溪县| 定远县| 常山县| 鹤岗市| 霍州市| 凤冈县| 北安市| 大英县| 行唐县| 赤壁市| 辽源市| 六枝特区| 佳木斯市| 武汉市| 溧阳市| 保德县| 肇州县| 龙江县| 尼勒克县|