iPhone: Detecting user inactivity/idle time since last screen touch

前端 未结 9 1400
我寻月下人不归
我寻月下人不归 2020-11-22 17:10

Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I\'m trying to figure out the best way t

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 17:36

    Actually the subclassing idea works great. Just don't make your delegate the UIApplication subclass. Create another file that inherits from UIApplication (e.g. myApp). In IB set the class of the fileOwner object to myApp and in myApp.m implement the sendEvent method as above. In main.m do:

    int retVal = UIApplicationMain(argc,argv,@"myApp.m",@"myApp.m")
    

    et voilà!

提交回复
热议问题