IOS第15天(1,事件处理View的拖拽)
*******view 一些方法
#import "HMView.h" @implementation HMView
// 一个完整的触摸过程
// touchesBegan -> touchesMoved -> touchesEnded /*
NSArray 集合 有序
NSSet 无序 */ // 触摸开始
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// 获取一个UITouch
UITouch *touch = [touches anyObject]; // NSLog(@"%s----%d",__func__,touches.count);
// NSLog(@"%d",touch.tapCount);
// NSLog(@"%d",touch.phase);
}
// 手指移动
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// 获取一个UITouch
UITouch *touch = [touches anyObject]; // 获取当前的位置
CGPoint current = [touch locationInView:self];
// 获取上一个点
CGPoint pre = [touch previousLocationInView:self]; // x轴偏移量
CGFloat offsetX = current.x - pre.x;
CGFloat offsetY = current.y - pre.y;
NSLog(@"%@",NSStringFromCGPoint(current)); // 获取视图的center
CGPoint center = self.center;
center.x += offsetX;
center.y += offsetY;
self.center = center; } // 触摸结束
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// 获取一个UITouch
UITouch *touch = [touches anyObject];
// NSLog(@"%d",touch.phase);
// NSLog(@"%s----%p",__func__,touch); } // 触摸被打断 比如打电话过来
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{ } @end
IOS第15天(1,事件处理View的拖拽)的更多相关文章
- iOS 未读消息角标 仿QQ拖拽 简单灵活 支持xib(源码)
一.效果 二.简单用法 超级简单,2行代码集成:xib可0代码集成,只需拖一个view关联LFBadge类即可 //一般view上加角标 _badge1 = [[LFBadge alloc] init ...
- IOS第15天(3,事件处理,手势处理)
7> 手势识别 使用UIImageView原因:之前既能看见图片,又能监听点击的只有UIButton,学了手势,我们的UIImageView也可以. * tap(代理:左边不能点,右 ...
- IOS第15天(2,事件处理,侧滑菜单,抽屉效果)
******HMDrawViewController.m #import "HMDrawViewController.h" @interface HMDrawViewControl ...
- IOS第15天(2,事件处理hitTest练习)
***hitTest 获取最合适的点 @implementation HMGreenView - (void)touchesBegan:(NSSet *)touches withEvent:(UIEv ...
- IOS 拖拽事件(手势识别)
@interface NJViewController () @property (weak, nonatomic) IBOutlet UIView *customView; @end @implem ...
- AJ学IOS(36)UI之手势事件旋转_缩放_拖拽
AJ分享,必须精品 效果 完成一个图片的捏合缩放,拖拽,旋转动作. 设计思路 拖拽: 首先是最简单的拖拽 //拖拽 -(void)panTest { UIPanGestureRecognizer *p ...
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
iOS开发UI篇—使用picker View控件完成一个简单的选餐应用 一.实现效果 说明:点击随机按钮,能够自动选取,下方数据自动刷新. 二.实现思路 1.picker view的有默认高度为162 ...
- 【IOS笔记】Creating Custom Content View Controllers
Creating Custom Content View Controllers 自定义内容视图控制器 Custom content view controllers are the heart of ...
- iOS 9 学习系列:UIStack View
http://www.cocoachina.com/ios/20150921/13492.html 在 iOS9 中,Apple 引入了 UIStackView,他让你的应用可以通过简单的方式,纵向或 ...
随机推荐
- Python与Hack之Unix口令
1.在实验时候,先导入crypt库:必须在Unix环境下才能实现这个模块 2.代码贴一下,以后有了Unix环境试试吧: import cryptimport syssys.modules['Crypt ...
- Java类与对象的基础学习
1. 请输入并运行以下代码,得到什么结果? public class Test{ public static void main(String args[]){ Foo obj1=new Foo(); ...
- 使用Spring的JAVA Mail支持简化邮件发送
http://www.cnblogs.com/codeplus/archive/2011/11/03/2232893.html
- WPF拖放功能实现zz
写在前面:本文为即兴而作,因此难免有疏漏和词不达意的地方.在这里,非常期望您提供评论,分享您的想法和建议. 这是一篇介绍如何在WPF中实现拖放功能的短文. 首先要读者清楚的一件事情是:拖放主要分为拖放 ...
- BZOJ4421 : [Cerc2015] Digit Division
如果两个相邻的串可行,那么它们合并后一定可行,所以求出所有可行的串的个数$t$,则$ans=2^{t-1}$. 注意特判整个串不可行的情况,这个时候答案为0. #include<cstdio&g ...
- HDU 3333 & 离线+线段树
题意: 统计一段区间内不同数字之和.如1 1 2 3 1 统计2---5即1+2+3. SOL: 很少打过离线的题目...这种可离线可在线的题不管怎么样一般都是强行在线... 考虑这题,此前做过一个类 ...
- HDU 2838 (DP+树状数组维护带权排序)
Reference: http://blog.csdn.net/me4546/article/details/6333225 题目链接: http://acm.hdu.edu.cn/showprobl ...
- Darkest page of my coding life
The code i wrote a while ago recently caused a disaster and as I reviewed it I found it is the silli ...
- ubifs总体设计分析
1. 设计需求 flash设备区别与一般的块设备,有如下特点: 存在坏块 使用寿命较短 存储介质不稳定 读写速度慢 不支持随机访问(nand) 只能通过擦除将0改成1 最小读写单位为page ...
- Leetcode Reverse Words in a String
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...