9

I've designed a launch screen using story board. It's supposed to have 3 images. 2 of these are static, where as, i need to update one at run time (after downloading that from server).

My understanding is that we can not add code for launch screen as there is no controller for this at backend.

What i want to do is to use some default place-holder for the first time. Download & cache that dynamic image at some other point in application. And when user use the app for the 2nd time, show the cached image.

Any solution? Can i update xcassets at run time? Or can i update the image using keypath?

Update: Just found that launch screen and splash screen are 2 different things (Link). Adding content in launch screen dynamically is not possible. Whereas, using splash screen (without any need) is not recommended.

Community
  • 1
  • 1
Fayza Nawaz
  • 2,256
  • 3
  • 26
  • 61
  • I can give you one hint like you want to display one image downloaded from web before home page. So you could set splash screen exactly before home screen, so its one kind of launch screen that you make. – Jitendra Modi Jan 27 '17 at 11:04
  • Just check this answer It will help you http://stackoverflow.com/questions/30027960/change-splash-screen-image-programmatically – Jitendra Modi Jan 27 '17 at 11:04
  • You can have code in the launch screen so just so save the server image in docs folder and then on launch screen check if it exists, if so put that in, I think this should work ? – Sean Lintern Jan 27 '17 at 11:11
  • @SeanLintern88 you can't have code in your launch screen! – rckoenes Jan 27 '17 at 11:14
  • Thats weird because I am using the 'Launch screen file' in project settings as a storyboard, which has 1 VC in it which is linked to a file that performs and animation, then transitions to another screen, and it all works – Sean Lintern Jan 27 '17 at 11:19
  • @SeanLintern88 just a label an update the value of it in the viewController, you will see nonthig happens. – rckoenes Jan 27 '17 at 11:25
  • @SeanLintern88, i'm unable to do that. – Fayza Nawaz Jan 27 '17 at 11:30
  • I perform an animation which I see everytime :/ – Sean Lintern Jan 27 '17 at 11:30
  • can you kindly explain in the answer section, how you created launch screen and added code? As, as per my knowledge, we can not.. If it's possible, then every thing will be solved! @SeanLintern88 – Fayza Nawaz Jan 27 '17 at 11:32
  • The thing is, Its in an inherited project that is very messy, there could be other things going on that are not obvious from initially looking – Sean Lintern Jan 27 '17 at 11:39
  • I would suggest just making a dummy screen as mentioned before – Sean Lintern Jan 27 '17 at 11:40
  • @SeanLintern88, thank you :) – Fayza Nawaz Jan 27 '17 at 11:42

1 Answers1

12

This is not possible, the story board used at launch time is in the main bundle of the application which is readonly and can not be changed.

Also you (edit) can't run any code on startup, since your app is not running.

Jeff
  • 2,659
  • 1
  • 22
  • 41
rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • What about my comment above? Will it solve some kind of it or not ? I know this is not possible, but it is possible to do like that – Jitendra Modi Jan 27 '17 at 11:10
  • Yes you could load a second screen after the launch screen, that is possible. But you don't want to delay the starting of your app. – rckoenes Jan 27 '17 at 11:13
  • hmm, and also I think it will more delayed for downloading image and then display for fix amount of time. So its better not to do that. Thanks – Jitendra Modi Jan 27 '17 at 11:14
  • @rckoenes, can't we use runtime? like keypath etc? or can't we update xc-assets programatically?? – Fayza Nawaz Jan 27 '17 at 11:30
  • 1
    @FayzaNawaz no, since the launch screen is used will your app is loading therefor no code is running and the assets used by the launch screen are again in the main bundle which is readonly. – rckoenes Jan 27 '17 at 11:35
  • One quick question. How does facebook achieve this? When user is not signed in, the launch screen (NOT Splash) is full blue. But when user signs in the launch screen is white with a blue tabbar at the top. Yes i am talking about launchscreen and not splashscreen. I know the difference – Saheb Roy Jun 27 '18 at 07:42
  • Bit late, but for me it shows the launch-screen in both account with the white-background and tabbar. – rckoenes Nov 09 '18 at 16:06
  • This goes against apple guidelines that launch screen should mimic the first screen of the app. The first screen of most apps depends on whether user has previously logged in or not, so you wouldn't know which screen to mimic https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/launch-screen/ – aryaxt Jul 20 '20 at 16:51