zoukankan      html  css  js  c++  java
  • Chapter 12 Touch Events and UIResponder

    Chapter 12  Touch Events and UIResponder

     

    1.As a subclass of UIResponder, a UIView can override four methods to handle the distinct touch events:

    a finger or fingers touches the screen:

    -(void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event

    a finger or fingers moves across the screen (this message is sent repeatedly as a finger moves)

    -(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event

    a finger or fingers is removed from the screen

    -(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event

    a system event, like an incoming phone call, interrupts a touch before it ends

    -(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;

     

    2. When a finger touches the screen, an instance of UITouch is created. The UIView that this finger touched is sent the message touchesBegan:withEvent: and the UITouch is in the NSSet of touches.

     

    3. How touch objects work:

    One UITouch corresponds to one finger on the screen. This touch object lives as long as the finger is on the screen and always contains the current position of the finger on the screen.

    The view that the finger started on will receive every touch event message of that finger no matter what. If the finger moves outside of the UIView’s frame that it began on, that view still receives the touchesMoved:withEvent: and touchesEnded:withEvent: messages. Thus, if a touch begins on a view, then that view owns the touch for the life of the touch.

    You do not have to - nor should you ever - keep a reference to a UITouch object. The application will give you access to a touch object when it changes state.

     

     

     

     

     

     

  • 相关阅读:
    jsp文件中charset和pageEncoding的区别
    如果jsp表单元素的值为空,如何避免null出现在页面上?
    C# 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序。
    正则表达式
    事件委托与键盘事件
    事件对象的兼容性
    作用域解析题
    事件冒泡与事件铺获的解析
    浏览器内核
    js中级总结
  • 原文地址:https://www.cnblogs.com/1oo1/p/3987183.html
Copyright © 2011-2022 走看看