(ios) 屏幕触摸总结
1 屏幕触控实现(单击 双击)
[self becomeFirstResponder];
//允许多点互动
self.view.multipleTouchEnabled=TRUE;
实现事件部分
#pragma mark-
#pragma mark touch - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ //触摸开始 } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{ //移动 } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
//结束
UITouch *atouch=[touches anyObject];
if(atouch.tapCount>=)
{
//双击
}
else if(atouch.tapCount==)
{ //单击
}
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{ }
2 手势识别(UIlabel 点击事件实现)
//设置图片的点击事件
UITapGestureRecognizer *recongnizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTapFrom:)];
recongnizer.numberOfTapsRequired=;
self.img.userInteractionEnabled=YES;
[self.img addGestureRecognizer:recongnizer];
} -(void)handleTapFrom:(UITapGestureRecognizer *)recognizer{
[self updateDisplayValuesWithTip:@"tap" tapCount: touchCount:];
}
3 屏幕晃动实现
//AppDelegate 中实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.applicationSupportsShakeToEdit = YES;
} //或者代码中实现
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES]; //ViewController 中实现下面方法 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);
{ }
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0)
{
if (event.subtype == UIEventSubtypeMotionShake) { //摇一摇 行为 }
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0)
{ }
4 图片滑动换页
UISwipeGestureRecognizer *recognizer;
self.img.userInteractionEnabled=YES;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self img] addGestureRecognizer:recognizer]; }
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"Swipe received."); if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
NSLog(@"swipe down");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
//界面变化部分
//........ [UIView commitAnimations];
}
}
(ios) 屏幕触摸总结的更多相关文章
- iOS中—触摸事件详解及使用
iOS中--触摸事件详解及使用 (一)初识 要想学好触摸事件,这第一部分的基础理论是必须要学会的,希望大家可以耐心看完. 1.基本概念: 触摸事件 是iOS事件中的一种事件类型,在iOS中按照事件划分 ...
- iOS的触摸事件的用法以及和手势识别器的区别
1.首先来介绍下触摸事件和手势识别器的利与弊 触摸事件和手势识别器二者之间有直接的关系 手势识别器是在触摸事件的基础上演变过来的 当我们用到触摸事件时 默认的uiview是没有什么效果的 只能自定义v ...
- iOS屏幕适配
## iOS屏幕适配 ### iOS屏幕适配发展史 1> iPhone4以前(没有iPad) * 不需要屏幕适配 2> iPad.iPhone5等设备出现 * 需要做横竖屏适配 * aut ...
- Auto Layout 在iOS屏幕适配中的使用
前几天在做iOS屏幕的适配,也就是让同样的UI控件的布局在不同屏幕的iOS设备上面都正确显示,storyBoard就无可避免的用到了Auto Layout.在这个过程中,我发现要熟练掌握Auto La ...
- iOS屏幕尺寸和分辨率
iOS平台家族成员主要包括iPhone.iPod Touch和iPad,但是各类设备的分辨率各不相同,目前存在的尺寸主要有: iOS设备的尺寸多种多样,此外,屏幕的分辨率也有多种,总结如下表所示: 其 ...
- 【转】iOS屏幕适配
一.iOS屏幕适配发展历程 设备 适配技术 4及以前(iPad未出) 直接用代码计算 有了iPad autoResizing 有不同屏幕的iPhone后 autoLayout 有更多不同屏幕的iPho ...
- Windows Phone中使用Storyboard做类似 IOS 屏幕小白点的效果
windows phone中做动画其实很方便的,可以使用Blend拖来拖去就做出一个简单的动画,下面做了一个 ios屏幕小白点的拖动效果,包括速度判断移动 使用Blend生成以下代码 <Stor ...
- iOS屏幕旋转 浅析
一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...
- iOS屏幕适配-iOS笔记
学习目标 1.[了解]屏幕适配的发展史 2.[了解]autoResizing基本用法 3.[掌握]autoLayout 的基本用法 4.[掌握]autoLayout代码实现 5.[理解]sizeCla ...
随机推荐
- 使用System.IO来读取以及修改文本文件
//1.读取html内容 string htmlUrl = @"new\new.html"; string htmlContent = string.Empty; using (S ...
- Firemonkey 在 iOS 平台能显示更多的 emoji 字符
使用 Firmonkey 在显示 emoji 字符时,有些 emoji 并无法显示彩色,见下图: 经查 FMX 源码,是因为判断 emoji 的字符区段不足造成的,经过修改后,便可显示,见下图: 修改 ...
- 袋鼠过河---DP
题目:一只袋鼠要从河这边跳到河对岸,河很宽,但是河中间打了很多桩子,每隔一米就有一个,每个桩子上都有一个弹簧,袋鼠跳到弹簧上就可以跳的更远,每个弹簧力量不同,用一个数字代表它的力量,如果弹簧力量为5, ...
- 三星s4刷机教程(卡刷)
···············使用到的工具···················手机助手(--推荐91助手).root精灵.Odin3 v3.07.recovery包.rom包 1.首先在电脑上安装9 ...
- python补充最常见的内置函数
最常见的内置函数是: print("Hello World!") 数学运算 abs(-5) # 取绝对值,也就是5 round(2. ...
- 【Effective Java】10、java注解使用
package cn.xf.cp.ch02.item35; import java.lang.annotation.ElementType; import java.lang.annotation.R ...
- hibernate(四)__由表逆向创建Domain对象和对象关系映射文件
之前我们是手写Domain对象和对象关系映射文件->然后生成数据库中的Table. 现在我们反过来先在数据库中建好Table->然后用工具生成Domain对象和对象关系映射文件. 步骤: ...
- 【我的产品观】开发wangEditor一年总结
1. 引言 标题说是一周年,其实是不是正好是一周年,我也忘记了,光从github的提交记录看也不准确.印象中觉得,如果要论想法,到现在一年多了,如果要论实际写代码,可能差不多正好一年. 从8月底在济南 ...
- Mega Dropdown - 带子分类的响应式下拉菜单
当你在开发一个内容很多的 Web 项目的时候,最具挑战性的部分之一是为了如果更方便用户浏览这些内容.我们都能想到的一个例子是 Amazon,无限的类别以及它们的子类别.Mega Dropdown 是带 ...
- OpenGL中旋转平移缩放等变换的顺序对模型的影响
l 前提: 0x01. 假设绘制顶点的语句为Draw Array,变换的语句(旋转.平移.缩放)为M,而 M0; M1; M2; Draw Array; 则称对Array先进行M2再进行M1.M0 0 ...