Iphone application gets stuck after unlocking screen

Go To StackoverFlow.com

0

When i keep my application open for awhile, the iPhone/iPod locks the screen. When i unlock it my application gets stuck for like 2 seconds and then it resumes and keep functioning as usual. Why is this ? and how can i prevent it ?

To prevent this from hapenning is there any PLIST method where we could stop the process of the application when it goes to a locked screen (Might not be a better idea)

2012-04-05 17:44
by Illep
did you find anything for this? this is happening with me too.. - Fahim Parkar 2017-06-19 13:42
I don't think I remember the solution, since I posted this 5 years ago. But, I think it was due to a memory issue. The method applicationDidReceiveMemoryWarning should help you to verify if its memory issue. Also as @Alex states you can goto Product > Profile > Leaks to track memory leaks - Illep 2017-06-20 05:42


0

I'm not quite sure about the answer for your first question (you maybe do some heavy things inside the applicationDidBecomeActive method or the app simply reallocates memory), but i can answer the second one.

You can simply prevent the auto lock by calling:
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
A good palce for this is inside the applicationDidFinishLaunching method of the app delegate.

2012-04-05 17:50
by yinkou
Where should i add this ? and does apple encourage to kill the app once its in an idle state - Illep 2012-04-05 17:54
The best place for this is inside the applicationDidFinishLaunching method of the app delegate. Updated the answer with that. And yes, iOS kills certain apps when it needs the resources - yinkou 2012-04-05 17:58


0

In your application delegate do you have any code that could slow down your app? Check the following methods?

  • -(void) applicationWillResignActive:(UIApplication *)application
  • -(void) applicationDidBecomeActive:(UIApplication *)application
  • -(void) applicationDidEnterBackground:(UIApplication*)application
  • -(void) applicationWillEnterForeground:(UIApplication*)application
  • -(void) applicationWillTerminate:(UIApplication *)application

Also use the above methods ensure you application suspends properly.

Log when your app receives a memory warning inside:

-(void) applicationDidReceiveMemoryWarning:(UIApplication *)application

Maybe when you suspend or reopen your app some there is a memory issue.

2012-04-05 17:57
by Alex L
I don't have anything in those methods. How could i suspend the app properly ? How could i print a memory warning in the applicationDidReceiveMemoryWarning method - Illep 2012-04-05 18:07
In applicationDidReceiveMemoryWarning just say NSLog(@"received a memory warning"). Run your app using Product > Profile > Leaks to track the memory leaks - Alex L 2012-04-05 18:58
Ads