화면상의 접촉을받는 UIWindow
에 UITapGestureRecognizer
을 사용할 수 있습니다. 여기에 그 timeOut 함수가 호출 한 후 5 초 동안 타이머를 추가했습니다.
Appdelegate
var window: UIWindow?
var timer: Timer?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let tapGesture = UITapGestureRecognizer(target: self, action: nil)
tapGesture.delegate = self
window?.addGestureRecognizer(tapGesture)
//Start timer for first time
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.timeOut), userInfo: nil, repeats: false)
return true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
print(" tapped on screen,")
timer?.invalidate()
//set Timer Ex: 5 Second
//Run timer on touch
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.update), userInfo: nil, repeats: false)
return false
}
@objc func timeOut() {
print("TimeOut")
}
그것은,있는 tableView 스크롤과 탭, UItextView 스크롤, 라벨 탭, 버튼 탭, UIWindow' : – Jack
덕분에 많은 잭'에있는 모든 개체를 작품에
UIGestureRecognizerDelegate
추가 – Senthilkumar