vimal nagar
vimal nagar

Reputation: 21

How to know if user is interacting with app

I need to perform some Heavy UI task.Before starting that task , I want to check if user is interacting with app , like scrolling the table or entering input in textfield. Is there any way to check it ?

Upvotes: 2

Views: 852

Answers (1)

Nicolas Miari
Nicolas Miari

Reputation: 16246

It is hard to tell without knowing the specifics -or what your "heavy UI task" is (heavy tasks should be performed in the background in order to not block the UI!), but perhaps your best shot is to do what you would do to detect (e.g.) long periods of your app not being used:

Override the method -sendEvent: of the UIApplication class.

Example:

override func sendEvent(event: UIEvent)
{
    super.sendEvent(event)

    // Do your stuff 
    // (e.g., update timestamp of last user interaction)
}

Upvotes: 1

Related Questions