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

首頁 > 系統 > iOS > 正文

ios觸屏事件指南

2019-10-21 18:57:43
字體:
來源:轉載
供稿:網友
這篇文章主要給大家總結介紹了2種實現ios觸屏事件的方法,簡單實用,有需要的小伙伴可以參考下。
 

 

復制代碼代碼如下:

//在一個函數里面(初始化等)里面添加要識別觸摸事件的范圍
    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()); 

 

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



注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 商城县| 甘肃省| 封丘县| 平邑县| 湘乡市| 锡林郭勒盟| 宜州市| 温宿县| 泰兴市| 松溪县| 鹤庆县| 灵丘县| 类乌齐县| 张家口市| 绥中县| 塔河县| 台前县| 德清县| 玉山县| 家居| 共和县| 九龙县| 岢岚县| 丰城市| 体育| 泗洪县| 常州市| 合江县| 建德市| 绥宁县| 上林县| 邻水| 尉氏县| 郧西县| 潼南县| 耒阳市| 广河县| 莎车县| 曲沃县| 前郭尔| 开鲁县|