[英]how to use touchesBegan and touchesEnded?
我在ViewController上添加了以下代碼
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("started")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
print("ended")
}
但它根本不打印任何消息。
UIResponder類是用於響應和處理事件的抽象接口Apple API參考
UIWindow,UIViewController,UIView是UIResponder的子類
如果要使用touchesBegan
和touchesEnded
,請覆蓋它
觸摸事件關注響應者鏈,請參閱蘋果文檔
發生了一些觸摸事件,並且您的ViewController的視圖成為下一個響應者,並且成功進行了hittest touchesBegan
在觸摸開始時被調用,而touchesEnded
被稱為touch結束
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.