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 ?
Asked
Active
Viewed 660 times
2
-
What would you want to do if they are and what if they are not? It may have an impact on solutions/available options. – MikeT May 24 '16 at 02:23
-
I need to insert multiple rows in the tableview. When I do that it block the UI for some time.If user is interacting with the app , I won't insert the row, so that user don't get blocked. – vimal nagar May 24 '16 at 02:41
1 Answers
1
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)
}

Nicolas Miari
- 16,006
- 8
- 81
- 189
-
The problem is I need to perform the UI task. So I can't do it on background thread.Thanks for the suggestion. Let me try it. – vimal nagar May 24 '16 at 02:18
-
I don't remember how to make the app use your `UIApplication` subclass for the application object (instead of the stock `UIApplication` itself), in swift. A web search should give you the answer. Good luck! – Nicolas Miari May 24 '16 at 02:23