首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏陈满iOS

    iOS· UIGestureRecognizer 与UITouch 的 locationInView方法含义区别

    UIGestureRecognizerDelegate - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch gestureRecognizer locationInView:self.view].y<self.functionalView.y) { return YES; } } UITouch UIGestureRecognizerDelegate - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch UIGestureRecognizer 与UITouch 都有一个 locationInView: 方法。

    1.4K10发布于 2018-09-10
  • 来自专栏xx_Cc的学习总结专栏

    iOS-UITouch事件处理详解1. iOS中的事件基本介绍2.UITouch3.UIEvent4. 事件的产生和传递5. 通过UITouch方法监听View的触摸事件的缺点

    远程控制事件 - (void)remoteControlReceivedWithEvent:(UIEvent *)event; 2.UITouch 1. UITouch的创建 当用户用一根手指触摸屏幕时,会创建一个与手指相关联的UITouch对象,一根手指对应一个UITouch对象。 2. UITouch的作用 UITouch保存着跟手指相关的信息,比如触摸的位置、时间、阶段等。 当手指移动时,系统会更新同一个UITouch对象,使之能够一直保存该手指在的触摸位置。 当手指离开屏幕时,系统会销毁相应的UITouch对象。 3. touches中UITouch的个数可以判断出是单点触摸还是多点触摸 4.

    2.2K60发布于 2018-05-10
  • 来自专栏全栈程序员必看

    CCLayer在Touch事件(Standard Touch Delegate和Targeted Touch Delegate)

    假设是单点touch,则仅仅须要调用 UITouch *touch = [touches anyObject],就能够获取touch对象。假设须要响应多点 touch。 则须要调用[[event allTouches] allObjects]返回一个UITouch的NSArray对象。然后使用NSArray的objectAtIndex依次訪问各个UITouch对象。 为了获取UITouch对象的坐标(如果该UITouch名称为touch),调用[touch locationInView: [ touch view]]会返回一个UIView相关的坐标viewPoint – (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event; (必须实现) – (void)ccTouchMoved:(UITouch 方法,该方法对每一个UITouch进行响应并返回一个BOOL值。

    1.7K10编辑于 2022-07-05
  • 来自专栏全栈程序员必看

    touchesBegan: withEvent: 不执行解决

    touchesBegan: withEvent: / touchesMoved: withEvent: / touchesEnded: withEvent: 等来实现 //// UIScrollView+UITouch.m //#import "UIScrollView+UITouch.h"@implementation UIScrollView (UITouch)- (void)touchesBegan:(NSSet<UITouch

    1.7K20编辑于 2022-09-15
  • 来自专栏iOS逆向与安全

    iOS 小技能: Responder Chain(响应者链)【上篇】

    当用户用一根手指触摸屏幕时,会创建一个与手指相关联的UITouch对象;一根手指对应一个UItouch对象。 2.1 UITouch的作用 保存着跟手指相关的信息,比如触摸的位置、时间、阶段。 1, 当手指移动时,系统会更新同一个UITouch对象,使之能够一直保存该手指的触摸位置。2. NSSet <UITouch *> *)touchesForView:(UIView *)view; - (nullable NSSet <UITouch *> *)touchesForGestureRecognizer - (nullable NSArray <UITouch *> *)coalescedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0); - (nullable NSArray <UITouch *> *)predictedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0);

    1.6K30编辑于 2022-08-22
  • 来自专栏全栈程序员必看

    关于iPhone多点触控

    *)touches withEvent:(UIEvent *)event { NSArray *twoTouches = [touches allObjects]; UITouch *firstTouch = [twoTouches objectAtIndex:0]; UITouch *secondTouch = [twoTouches objectAtIndex:1]; touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0]; UITouch *touch2 = [[allTouches allObjects]

    87120编辑于 2022-07-15
  • 来自专栏全栈程序员必看

    touchesBegan 触摸事件

    二、UIReponder类 UIResponder内部提供了一下方法来处理事件,父类是NSObject 1、触摸事件 1)手指按下事件 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event; 2)手指移动事件 - (void)touchesMoved:(NSSet<UITouch *> *) touches withEvent:(nullable UIEvent *)event; 3)手指抬起事件 - (void)touchesEnded:(NSSet<UITouch *> *)touches 类 UITouch父类是NSObject,存放在NSSet中,无序且不能重复,通过anyObject来访问单个元素。 ,系统会销毁相应的UITouch对象。

    1.4K20编辑于 2022-09-15
  • 来自专栏全栈程序员必看

    ios事件-触摸事件3(UIButton 和 pointInSide()、hitTest()、touchesBegan()、touchesMoved()、touchesEnded()的关系)

    , %s", __func__); [super touchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet<UITouch , %s", __func__); [super touchesMoved:touches withEvent:event]; } - (void)touchesEnded:(NSSet<UITouch s", __func__); [super touchesEnded:touches withEvent:event]; } - (void)touchesCancelled:(NSSet<UITouch ", __func__); return [super hitTest:point withEvent:event]; } - (void)touchesBegan:(NSSet<UITouch (@"%s", __func__); [super touchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet<UITouch

    85920编辑于 2022-09-15
  • 来自专栏全栈程序员必看

    touchesBegan: withEvent: 不执行/完美收起键盘

    eg:写一个category类目 UIScrollView + Event – (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent 材料:BaseViewController(这是所有ViewController的基类) 1.在BaseViewController写入 -(void)touchesBegan:(NSSet<UITouch 2.写一个category类目 UIScrollView + Event.h – (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:( 写一个category类目 UIButton + Event.h – (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent

    1.1K30编辑于 2022-09-15
  • 来自专栏MelonTeam专栏

    iOS 事件体系知识及原理小记

    基本知识点: 0 UITouch 当每一个指尖在屏幕上触发一次触摸事件时,系统就会生成对应一个UITouch对象,用于记录当前触摸的状态,主要包含运动相位、位置、大小、运动、力度(iOS9)等数据; 当触摸事件发生变化时(指尖移动、压力变化),UITouch对象的相关信息也会跟着更新;每一次更新都是复用之前的UITouch对象,不会重新创建。 UIEventSubtype  subtype NS_AVAILABLE_IOS(3_0); // 在各个大类型中再细化区分 @property(nonatomic, readonly, nullable) NSSet <UITouch *> *allTouches; // 当前事件触发时的所有UITouch对象 2 UIResponder 事件响应者(UIResponder)的查找与事件的响应: 响应者(responder)的概念: 则返回当前view; 如果点击没有落在当前view,则返回nil; 响应者查找阶段就要用到这两个方法,大致流程如下: 当指尖触碰屏幕时,系统会创建一个UIEvent对象(如果已经存在,则复用),以及相应的UITouch

    1.5K90发布于 2018-01-04
  • 来自专栏学海无涯

    iOS18适配指南之UIViewController

    super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch

    34510编辑于 2025-02-10
  • 来自专栏学海无涯

    iOS18适配指南之UIViewController

    super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch super.viewDidLoad() view.backgroundColor = .green } override func touchesBegan(_ touches: Set<UITouch

    77111编辑于 2024-09-09
  • 来自专栏学海无涯

    iOS14开发-触摸与手势识别

    触摸 概念 UITouch 用于描述触摸的窗口、位置、运动和力度。一个手指触摸屏幕,就会生成一个 UITouch 对象,如果多个手指同时触摸,就会生成多个 UITouch 对象。 -> CGPoint UIEvent 一个完整的触摸操作是一个 UIEvent,它包含一组相关的 UITouch 对象,可以通过 UIEvent 的allTouches属性获得 UITouch 的集合。 // 手指触碰屏幕,触摸开始 open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) // 手指在屏幕上移动 open func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) // 手指离开屏幕,触摸结束 open func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)

    3.4K20发布于 2021-05-10
  • 来自专栏全栈程序员必看

    touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event使用

    而这几个方法被调用时,正好对应了UITouch类中phase属性的4个枚举值。 上面的四个事件方法,在开发过程中并不要求全部实现,可以根据需要重写特定的方法。 其中touches表示触摸产生的所有UITouch对象,而event表示特定的事件。 例如: – ( void )touchesEnded:(NSSet * )touches withEvent:(UIEvent * ) event { UITouch 例如: – ( void )touchesEnded:(NSSet * )touches withEvent:(UIEvent * ) event { UITouch – ( void )touchesEnded:(NSSet * )touches withEvent:(UIEvent * ) event { UITouch

    87220编辑于 2022-09-15
  • 来自专栏CoderStar

    iOS 中的事件响应

    事件来由:UITouch 触摸 创建 每个手指每一次触摸屏幕,对应生成一个 UITouch 对象。多个手指先后触摸,系统会根据触摸的位置判断是否更新同一个 UITouch 对象。 若两个手指一前一后触摸同一个位置 (即双击),那么第一次触摸时生成一个 UITouch 对象,第二次触摸会更新这个 UITouch 对象,这是该 UITouch 对象的 tapCount 属性值从 1 变成 2; 若两个手指一前一后触摸的位置不同,将会生成两个 UITouch 对象,两者之间没有联系; 销毁 手指离开屏幕一段时间后,确定该 UITouch 对象不会再被更新,就释放。 列举 UITouch 对象一些关键属性及方法,可以留意一下,后文中的介绍会涉及到这些属性。 func beginTracking(_ touch: UITouch, with event: UIEvent?)

    4.3K11编辑于 2022-08-24
  • 来自专栏岑志军的专栏

    UITextField添加点击高亮状态

    } completion:^(BOOL finished) { }]; } #pragma mark - Overwrite - (void)touchesBegan:(NSSet<UITouch touchesBegan:touches withEvent:event]; [self setBackgroundHighlighted:YES]; } - (void)touchesMoved:(NSSet<UITouch nullable UIEvent *)event{ [super touchesMoved:touches withEvent:event]; } - (void)touchesEnded:(NSSet<UITouch touches withEvent:event]; [self setBackgroundHighlighted:NO]; } - (void)touchesCancelled:(NSSet<UITouch

    1.4K50发布于 2018-05-28
  • 来自专栏滕先生的博客

    touchesBegan 触摸事件一、概念介绍二、方法介绍三、参数介绍:touches四、参数介绍:event

    对象 如果这两根手指一前一后分开触摸同一个view,那么view会分别调用2次touchesBegan:withEvent:方法,并且每次调用时的touches参数中只包含一个UITouch对象 二、 触摸事件 (1)手指按下事件 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event; - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event; (4)意外中断事件(如电话打扰 ) - (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event; NSSet <UITouch *> *)touchesForGestureRecognizer:(UIGestureRecognizer *)gesture;

    3.1K100发布于 2018-05-18
  • 来自专栏sktj

    IOS UIResponder 触屏

    { override func viewDidLoad() { super.viewDidLoad() } override func touchesBegan(_ touches:Set<UITouch { print(“touchesBegan”); } override func touchesMoved(_ touches:Set<UITouch>, with event:UIEvent?) { print(“touchesMoved”); } override func touchesEnded(_ touches:Set<UITouch>,with event:UIEvent?) { print(“touchesEnded”); } override func touchesCancelled(_ touches:Set<UITouch>, with event:UIEvent

    1.7K30发布于 2019-07-08
  • 来自专栏TechBox

    【iOS】block小记

    block内不能直接set外部局部变量,否则会报错,错误代码如下: -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent 要想访问外部局部变量,外部局部变量必须用__block修饰,代码如下: -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { static int staticVar 代码如下: int globalVar = 10; -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 下面的blk就是一个全局block: -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { /

    5.6K40编辑于 2022-02-18
  • 来自专栏iOSer成长记录

    iOS-关于Cell上Button点击效果

    { [obj setDelaysContentTouches:NO]; } } } 解决方案二: -(void)touchesBegan:(NSSet<UITouch NSOperationQueue.mainQueue addOperationWithBlock:^{ self.highlighted = YES;}]; } -(void)touchesCancelled:(NSSet<UITouch performSelector:@selector(setDefault) withObject:nil afterDelay:0.1]; } -(void)touchesEnded:(NSSet<UITouch

    1.8K30发布于 2018-06-29
领券