1

I have to check if user did touch the screen.And perform some task if the application was idle for a time duration.
I know that how to use the TouchBegin and touchEnd method but my project is large and some objects are not responding to these methods.

Currently i am using timer in each and every interaction with the objects i know this is very bad way and there must be some good way to do this...

Can anyone suggest a better solution ?

Kumar sonu
  • 535
  • 11
  • 24

3 Answers3

2

Record the time that the last TouchUp event happened. You can then check that without the need for any timers.

koregan
  • 10,054
  • 4
  • 23
  • 36
1

You want one global timer which is cancelled and restarted on each touch end event.

Andrew Ebling
  • 10,175
  • 10
  • 58
  • 75
1

Why you are saying that some objects are not responding to TouchBegin and touchEnd methods.Without these methods how can you detect that the user had touched or not.i do not think that using timer in this situation will be a correct way .So make those objets to respond to these methods .

Try making a bool variable eg:- BOOL isTouched

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

      isTouched =  Yes;
}

Now make you conditions according to this bool variable Good Luck!

Sudhanshu
  • 3,950
  • 1
  • 19
  • 18