Quit MPMoviePlayer on entering background in iOS Objective-C - ios

MPMoviePlayer is presented on RootViewController.On entering background, I have popped the MPMoviePlayerController.
But on entering foreground,the movie player screen is splashed for a second and then disappears.
What I need is not to show the movie player view on entering foreground.
Is there any way to achieve this ?

It's because the system takes a snapshot of the application’s main window when an application moves on to the background, which is presented when you enter foreground.
Hope this will help you to understand things better.
Prevent iOS from taking screen capture of app before going into background
The exact moment iOS takes the view snapshot when entering background?

Related

Can I make my iphone app use only a portion of the screen

I was hoping to create a small windowed screen when the home button is pressed. It would keep a portion of the app process open while another app isn't open.
So say I had music playing on the app and when the home button gets pressed the screen would be windowed or shrunk and just displayed over the main screen (kind of like the little help button that can be moved around). Would using widgets in IOS 8 work?
When the user presses the Home button, the app goes to background, and that's it. You can't customize that action.
You only get a notification that the user closed the app so that you can save your app state or data for the next launch.

When app backgrounded lock screen does not fully animate in

Background
When the app is backgrounded I want to have a lock screen that forces the user to log in again. I have implemented this in the OnResignActivation method in AppDelegate.
Functionally this works fine, however, when backgrounded the lock screen tries to slide in but doesn't have time to complete. When the app opens again this animation completes.
Question
How can I get the animation to complete or not use the animation at all so that when ever the app is opened again the lock screen is there and not half way across?
Solution
The solution was in fact in implement the lock screen logic in DidEnterBackground instead of OnResignActivation in AppDelegate.
As the code was running to soon in the life cycle I was getting half an animation behaviour. Putting it in DidEnterBackground resolves this.
These SO answers helped me arrive at this solution.
https://stackoverflow.com/a/12416131/1593273
https://stackoverflow.com/a/25985478/1593273

Application navigated to home screen when tapped dismiss on devices low battery alert in iOS

These are the steps where this scenario is occurring:
I deployed my app and I navigated to several screens.
Due to low battery of my device I got a low battery alert.
When I tapped dismiss button from the low battery aler, My app is automatically navigating to the Home screen (i.e first screen)
Can anyone suggest me what might be the problem.
Whenever these system dialog pops up, your app though still in forground becomes inactive. And once you dismiss it, it becomes active again. If my guess is right, you must be doing something in applicationDidBecomeActive delegate method. You simply need to check that method and fix it.

IOS: forcing update before app becomes visible

I have a timer in my app, and I want it to appear to be running while my app is on the background. I'd like that if the user presses the home button when the timer shows, for instant "01:11:11" and then goes back to the app and it becomes visible to him 10 minutes later, to see the timer as "01:01:11", however I get a split second where it shows the last state when the app went to the background ("01:11:11") before it starts updating from the correct time.
I assumed that I could correct this by updating the state of my timer in "applicationDidBecomeActive" and it did work on my simulator in Xcode but not on my Ipad.
I'm using cocos2d for my drawing and this is what I'm doing in my applicationDidBecomeActive:
CCScene *s=[director_ runningScene];
GameLayer *l=[(GameLayer*)[s getChildByTag:GAME_LAYER_TAG];
if (l!=nil) [l myUpdate];
I don't think it's relevant to the problem though because myUpdate does get called but I still have that split second glitch on my Ipad, as if it starts back from its last state no matter what.
In apples clock app, in applicationDidEnterBackground it hides the timer text, so that when the app comes into the foreground you see a blank UI for the split second where your app is loading the new timer data in the UI. Also, you may want to call some of your applicationDidBecomeActive code in applicationWillEnterForeground, which is called first. But keep in mind, applicationWillEnterForeground is not called when the app first launches.
There will always be a delay between when your app comes into the foreground, and when the UI updates. Theres no way to fix that, so you might as well use what apple uses to get around the issue.
Well I tried to hide my UI in both applicationWillResignActive and applicationDidEnterBackground. Since applicationWillResignActive is called first and before going into preview (double click on HOME) it causes a "not so pretty" preview but I thought at least it would solve my original problem. It didn't (not, on my IPad). It looks like the system takes the screen shot even before applicationWillResignActive.
I checked the timer in the official clock app and I see the clock is updating even when the app is in the background (in preview), so they "cheat" anyway...

Show splash screen instead of snapshot

My issue is with the splash screen shown when the app opens while in suspended mode.
When the app is closed and i open it, i see the Default.png splash screen, which is what i need.
But if i send it to the background and reopen it, i see a snapshot from the last screen i was in, and i want to see the splash screen.
I have even considered forcing the app to quit on when entering background, but i'd rather show a snapshot than do this.
How can i accomplish this?
Thank you.
You can't change the image that is shown when the app starts (Default.png) or enters the foreground (snapshot of previous app state).
Ask yourself, how would showing a splash screen each time the app enters the foreground improve the user experience?
Edit: Here's a guess at a workaround:
Based on your comment below, it sounds like you're saying it would be OK if the user always came back to the main action screen. In the applicationWillResignActive: method, could you check what screen the users is on, and if it's not the main action screen, move back to that screen... the snapshot would be of the main action screen then (maybe!)

Resources