gpt4 book ai didi

ios - 保留 UITouch : allowed or not?

转载 作者:行者123 更新时间:2023-11-29 00:17:10 25 4
gpt4 key购买 nike

这里引用 documentation of UITouch :

A touch object persists throughout a multi-touch sequence. Never retain a touch object when handling an event. If you need to keep information about a touch from one touch phase to another, copy that information from the touch.

然后这是来自 Event Handling Guide for UIKit Apps 的另一则内容:

Listing 9-1 shows the main implementation of the TouchableView class and its touch handling methods. Each method iterates through the touches and performs the needed actions. The touchViews dictionary uses the UITouch objects as keys to retrieve the subviews being manipulated onscreen.

class TouchableView: UIView {
var touchViews = [UITouch:TouchSpotView]()
...
}

显然,他们使用 UITouch 实例作为字典键违反了自己的规则...

那么这到底是怎么回事呢?是否应该保留 UITouch 实例来进行复杂的手势跟踪?

最佳答案

我向 Apple 提交了一份关于示例代码与 UITouch 文档之间不一致的错误报告。结果是“处理事件时从不保留触摸对象”段落已从 UITouch documentation 中删除。 .自 sample code保留 UITouch 对象,因此我们可以假设它是允许的。

关于ios - 保留 UITouch : allowed or not?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45067293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com