iOS UI-手势(Gesture)
#import "ViewController.h" @interface ViewController ()<UIActionSheetDelegate>
@property (strong, nonatomic) UITextField *me_textfield; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor lightGrayColor]];
/*
手势分类:
滑动手势、点击手势、双击手势、长按手势等7种
*/ // self.me_textfield = [[UITextField alloc] initWithFrame:CGRectMake(0, 100, 375, 100)];
// self.me_textfield.placeholder = @"请输入";
// self.me_textfield.borderStyle = UITextBorderStyleRoundedRect;
// //self.me_textfield.center =self.view.center;
// [self.view addSubview:self.me_textfield]; //创建点击手势
UITapGestureRecognizer *click = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToDoSomething)];
[self.view addGestureRecognizer:click]; //创建长按手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressToDoSomething)];
longPress.minimumPressDuration = 2.0;
[self.view addGestureRecognizer:longPress]; //创建捏合手势
UIPinchGestureRecognizer *pich = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pichToDoSomething)];
[self.view addGestureRecognizer:pich]; //创建旋转手势
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationToDoSomething)];
[self.view addGestureRecognizer:rotation]; //创建轻扫手势
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToDoSomething)];
[self.view addGestureRecognizer:swipe]; //创建拖动手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panToDoSomething)];
[self.view addGestureRecognizer:pan]; //创建屏幕边缘拖动手势
UIScreenEdgePanGestureRecognizer *screenEdgePan =[[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgePanToDoSomething)];
[self.view addGestureRecognizer:screenEdgePan];
}
#pragma mark - 屏幕边缘拖动手势关联方法
- (void)screenEdgePanToDoSomething
{
NSLog(@"屏幕边缘拖动");
}
#pragma mark - 拖动手势关联方法
- (void)panToDoSomething
{
NSLog(@"拖动");
}
#pragma mark - 轻扫手势关联方法
- (void)swipeToDoSomething
{
NSLog(@"轻扫");
}
#pragma mark - 旋转手势关联方法
- (void)rotationToDoSomething
{
NSLog(@"旋转");
}
#pragma mark - 捏合手势关联方法
- (void)pichToDoSomething
{
NSLog(@"捏合");
}
#pragma mark - 长按手势关联方法
- (void)longPressToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"关机" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show];
}
#pragma mark - 点击手势关联方法
- (void)clickToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"你点我试试" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
iOS UI-手势(Gesture)的更多相关文章
- 点击事件touches与ios的手势UIGestureRecognizer
.h文件 @property (weak,nonatomic) IBOutlet UILabel *messageLabel;@property (weak,nonatomic) IBOutlet U ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- android学习笔记52——手势Gesture,增加手势、识别手势
手势Gesture,增加手势 android除了提供了手势检测之外,还允许应用程序把用户手势(多个持续的触摸事件在屏幕上形成特定的形状)添加到指定文件中,以备以后使用 如果程序需要,当用户下次再次画出 ...
- android学习笔记51——SQLite 手势Gesture
手势Gesture 所谓手势,是指用户手指或触摸笔在触摸屏幕上的连续触碰行为. Androi对两种手势行为都提供了支持: 1.对于第一种手势而言,android提供了手势检测,并为手势检测提供了相应的 ...
- [IOS]IOS UI指南
[IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...
- [BS-25] IOS中手势UIGestureRecognizer概述
IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...
- IOS各种手势操作实例
先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击 UITapGestureRecogniz ...
- 国外IOS UI指南
国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...
- iOS UI的几种模式
iOS UI的几种模式: 1.平凡模式(原生控件组合): 2.新闻模式: 3.播放器模式: 4.微博模式:
- IOS中手势UIGestureRecognizer
通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...
随机推荐
- P3627 [APIO2009]抢掠计划
P3627 [APIO2009]抢掠计划 Tarjan缩点+最短(最长)路 显然的缩点...... 在缩点时,顺便维护每个强连通分量的总权值 缩完点按照惯例建个新图 然后跑一遍spfa最长路,枚举每个 ...
- Java并发之FairSync和NonfairSync
Java并发中的fairSync和NonfairSync主要区别为: 如果当前线程不是锁的占有者,则NonfairSync并不判断是否有等待队列,直接使用compareAndSwap去进行锁的占用; ...
- 20145321《网络对抗技术》逆向与Bof基础
20145321<网络对抗技术>逆向与Bof基础 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何 ...
- Win32 文件拖拽
1.响应系统消息 WM_DROPFILES 2.在响应函数里面获取拖拽文件路径 LRESULT OnDropFiles(UINT uMsg, WPARAM wParam, LPARAM lParam ...
- 零碎知识点 telnet操作IMAP查看邮件
1.用SQL语句查找出字符型字段内的最大值 select max(cast(字段 as int)) from 表 注:因为数据库是按字符比较的,10,9.因为9比1大,而只要有一位数字大,10后面就不 ...
- 分布式系统一致性协议--Paxos算法
Paxos: Paxos算法背景介绍: Paxos算法是分布式技术大师Lamport提出的,主要目的是通过这个算法,让参与分布式处理的每个参与者逐步达成一致意见.用好理解的方式来说,就是在一个选举过程 ...
- pip 更换国内镜像与记录
更换pip源到国内镜像 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/sim ...
- POJ 3533 Light Switching Game(三维Nim积)题解
思路:三维Nim积 代码: #include<set> #include<map> #include<stack> #include<cmath> #i ...
- ACM-ICPC 2018 南京赛区网络预赛 E AC Challenge 状压DP
题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0& ...
- [bzoj 1270][BeijingWc2008]雷涛的小猫
Description 雷涛的小猫雷涛同学非常的有爱心,在他的宿舍里,养着一只因为受伤被救助的小猫(当然,这样的行为是违反学 生宿舍管理条例的). 在他的照顾下,小猫很快恢复了健康,并且愈发的活泼可 ...