Change zoomScale and contentOffset of UIScrollView in UIApplicationStateBackground state - ios

I know it's not recommended to change any view appearance when the application is moved to background state, but for my specific task I cannot postpone this activity and I really like to complete it in a couple of seconds after the user hits the home button.
That's what I do:
I load a webpage in a UIWebView and after loading completion I change the contentOffset and zoomScale in order to make a specific screenshot of that webpage. When the app is in active application state everything works fine.
Now I wanted to add some more multitasking capabilities. I encapsulated the above described webpage loading and rendering activity in a protected background task (iOS Task Completion), in order to complete it even when the user hits the home button.
I have noticed that the page loading and the rendering of the webpage screenshot (with the renderInContext: method) works just fine in background, BUT it seems that the webview (i.e. the encapsulated UIScrollView instance) does not react on setContentOffset: and setZoomScale: messages as soon as the app is in background..
So I'm asking you if you know any alternatives to change the content offset / zoomscale? (modifications directly on CALayer?) Or any method to "force" the scrollview to perform the content changes even in background.
PS: On the iOS simulator everything works fine even in application background state, but on real devices it does not.
EDIT: I have created a simple demo project that demonstrates the issue. You can download it here (please read the instructions in the zip file): http://dl.dropbox.com/u/3556271/BackgroundBugDemo.zip
I appreciate every hint or tip. Thanks!

Related

Animation in Launch Screen in xcode 6

I want to animate a set of images in my Launch Screen, but I do not know how. I have seen some tutorials telling me to put code in the App Delegate (DidFinishLaunchingWithOptions) and nothing has worked.
Could someone help me animate my Launch Screen?
I am supposing that you do quite a bit of work on launch, and you do not want your user to stare at a static image while this work is going on. What you need to do is do the work in the background (using gcd). This way, the launch screen will be gone quickly. However, you are not ready of course: hence your need for animations. So what I do is add my own equivalent of the start screen on top of my first visible UIView, do my animations and then tear down my start up screen. If you want to see what I do in action, try it out with my App (The Opera Player)

iOS remove view before applicationWillEnterForeground

I'm developing an app on iOS 7 with a desired feature is that
When I home button, app enter background, I will add an image to current UIWindow. So when app enter background, if user double home button on iOS 7, os will show a small screenshot of current view of my app, so user can see my added image. :) (I did it)
When user return my app by clicking app icon, I want to remove this image immediately. In this situation, "immediately" means that user can NOT see this image anymore, user just see his/her current view when app enter foreground. I try to place the code remove image on the beginning of applicationWillEnterForeground delegate, but I'm still able to see this image for a short time after it disappears.
I also try to set hidden, alpha property for this imageview first, then removeFromSuperview, but it not works.
Can anyone help me to remove it "immediately" as my desire.
That is done automatically for all applications, you don't need to do anything in you code.
I don't think that you can do it faster, it depends of device performance. Sorry man.
Like other says it is really tricky how iOS handles these events. I've been researching and depends on the memory state of the device to do it faster or not. Indeed, in iPhone 4 and 4S may not show the image that you added on applicationWillEnterForeground method.
If I were you I would solve it by adding a smooth fade out animation of that image when the app becomes active again. With [UIView animateWithDuration: animations:] it could be nicely done! :)
If I find out something else I'll answer here!

Application life cycle iOS

I having a problem with the application life in iOS programming. My application has the view controller that has been subclassed for drawing. Everything went fine till I decide that went the app go inactive (Press Home). I want it to load a new screen. I used notifications of applicationWillEnterForeground and a few others. What happens the drawing code fails when I try to get the UIGraphicsGetCurrentContext, it comes back as nil. I assume I am attempting to get the context before it is available. What is the proper event. I think I tried all but the right one.

Can the startup/splash screen be changed depending upon the state of the application upon startup?

My app has a registration screen that is only presented once, and after registration is completed it is never shown again.
If my startup screen is a screenshot of the app then I would need to provide two screenshots and for the correct one to be initially displayed when the app launches.
Is this possible?
No, it is not currently possible. You cannot access the Default.png (or whatever you've named it instead) from your app to update it.
If it were me, I would set the startup screen to the one that is appropriate long term. You could also theoretically update your registration screen to be a bit closer to the look and feel of the main app screen, so it isn't so far off visually.

IOS: turn off camera

In my app I use iphone camera, but the process is very low when I open it; then I want to start the process when I shows a splashscreen.
The problem is that when splashscreen ends I don't want to show camera.
Then while I show splashscreen I want to start process of camera and quit it before splashscreen disappear. Is it possible?
First up, Apple specifically advise against using splash screens in their Human Interface Guidelines document. I don't know if your app would get rejected for it, but best not to try.
Second, it sounds like you need to optimise the startup of your application and probably the first view controller. To do this, you need to put off loading/initialising everything you can until it's actually needed (known as "lazy initialisation). All code in applicationDidFinishLaunching: in your app delegate and your view controller's init method, loadView, viewDidLoad, viewWillAppear, viewDidAppear should be reviewed for stuff that could be done later.

Resources