iOS开发-UISwipeGestureRecognizer滑动手势
滑动手势也算是iOS中交互中很重要的一部分,上下左右滑动,UISwipeGestureRecognizer可以很轻松的解决这个问题,没什么难度直接看代码吧:
UISwipeGestureRecognizer *upSwipeGestureRecognizer=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureRecognizer:)];
upSwipeGestureRecognizer.direction=UISwipeGestureRecognizerDirectionUp;
[self.view addGestureRecognizer:upSwipeGestureRecognizer]; UISwipeGestureRecognizer *downSwipeGestureRecognizer=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureRecognizer:)];
downSwipeGestureRecognizer.direction=UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:downSwipeGestureRecognizer]; UISwipeGestureRecognizer *leftSwipeGestureRecognizer=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureRecognizer:)];
leftSwipeGestureRecognizer.direction=UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:leftSwipeGestureRecognizer]; UISwipeGestureRecognizer *rightSwipeGestureRecognizer=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureRecognizer:)];
rightSwipeGestureRecognizer.direction=UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:rightSwipeGestureRecognizer];
手势处理:
-(void)swipeGestureRecognizer:(UISwipeGestureRecognizer *)recongnizer{
if (recongnizer.direction==UISwipeGestureRecognizerDirectionUp) {
NSLog(@"向上滑动");
NSLog(@"博客园-FlyElephant");
}
if (recongnizer.direction==UISwipeGestureRecognizerDirectionDown) {
NSLog(@"向下滑动");
NSLog(@"原文地址:http://www.cnblogs.com/xiaofeixiang");
}
if (recongnizer.direction==UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"向左滑动");
NSLog(@"iOS技术交流群:228407086");
}
if (recongnizer.direction==UISwipeGestureRecognizerDirectionRight) {
NSLog(@"向右滑动");
}
}
效果图:

iOS开发-UISwipeGestureRecognizer滑动手势的更多相关文章
- 李洪强iOS开发之添加手势
李洪强iOS开发之添加手势 02 - 添加手势
- iOS开发cell--滑动手势显示按钮
// 主要代码 #warning iOS8 - #pragma mark 在滑动手势删除某一行的时候,显示出更多的按钮 - (NSArray *)tableView:(UITableView *)ta ...
- iOS开发UI高级手势识别器
####手势识别器 UIGestureRecognizer类 ·UITapGestureRecognizer(轻击) ·UIPinchGestureRecognizer(捏合) ·UIPanGestu ...
- IOS开发中滑动页面时NSTimer停止的问题
我们在做倒计时的时候,发现当你手指按着屏幕不放,拖动tableView滑动的时候,写在cell上得倒计时停止倒计时,松开继续倒计时.研究发现就是拖动tableView滑动时,NSTimer停止了. 这 ...
- iOS开发 解决UITapGestureRecognizer手势与UITableView的点击事件的冲突
该篇文章摘自我的新浪博客,原文地址为: http://blog.sina.com.cn/s/blog_dcc636350102wavx.html UITableView 拥有属于自己的点击事件,在将一 ...
- iOS开发-UITableView滑动视差
视差滚动是指让多层背景以不同的速度移动,形成立体的运动效果,在Web上应用的比较多,App中倒是见的相对比较少,主要在UITableView中的应用的比较多,尤其是当整个UITableViewCell ...
- ios开发之滑动长图截全屏应用
最近做项目遇到要求截取图片长度超出手机屏幕,即可滑动的长图截屏,这里简单说一下解决思路,下面附带Demo下载地址. ,当我们要截全屏时,将滑动视图的frame以及偏移量记录下来,然后将滑动视图偏移量设 ...
- iOS开发-iOS7禁用手势返回
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 禁用 iOS7 返回手势 if ([self.nav ...
- IOS开发之---触摸和手势
Touch:在与设备的多点触摸屏交互时生成. 响应者对象 响应者对象就是可以响应事件并对事件作出处理.在iOS中,存在UIResponder类,它定义了响应者对象的所有方法.UIApplication ...
随机推荐
- Codeforces Round #369 (Div. 2) E. ZS and The Birthday Paradox 数学
E. ZS and The Birthday Paradox 题目连接: http://www.codeforces.com/contest/711/problem/E Description ZS ...
- Android中使用隐藏API(大量图解)
Android SDK的很多API是隐藏的,我无法直接使用.但是我们通过编译Android系统源码可以得到完整的API. 编译Android系统源码后可以在out\target\common\obj\ ...
- Dynamic-Link Library Redirection
Dynamic-Link Library Redirection Applications can depend on a specific version of a shared DLL and s ...
- ubuntu下安装ftp服务器
参考文献: 5.4 FTP 服务器 vsftpd - FTP 服务器安装 vsftpd 是可在 Ubuntu 中使用的 FTP 守护程序之一.它在安装.设置和维护方面十分方便.要安装 vsftpd 您 ...
- 利用 PHP 导出 Git 某个分支下,新增或修改过的文件
使用 SVN 作为版本控制的时候,整理过一个 导出文件脚本:利用 PHP 导出 SVN 新增或修改过的文件 现在换成了 Git,整理出类似的脚本: [第一版]git.php <?php /** ...
- Android WebView加载Html右边空白问题的解决方案
用WebView显示Html时,右边会出现一条空白区,如下图所示: 最开始的时候,认为是网页本身的空白. 后来发现网页本身无问题,且这个空白区是跟Scroll Bar 的位置和粗细比较相符,于是去控制 ...
- Plan Explorer数据库
Plan Explorer数据库 https://www.sentryone.com/platform/sql-server-performance-monitoring
- linux-socket connect阻塞和非阻塞模式 示例
~/cpp$ ./connect 192.168.1.234 1234 kkkk block mode: ubuntu 14.04 : time used:21.0.001053s connect ...
- zoj 1649
#include <iostream> #include <queue> using namespace std; int n,m,s2,e2; int b[205][205] ...
- leetcode 题解 || Valid Parentheses 问题
problem: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if ...