下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
//在一个函数里面(初始化等)里面添加要识别触摸事件的范围 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(@"****************向上滑****************"); }}
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的iOS相应触屏事件代码全部内容,希望文章能够帮你解决iOS相应触屏事件代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)