I have an app where the first screen user sees has data that is fetched from the server. The app also has a splash screen that shows up when the app is being loaded.
Problem Depending on the users connection time it might take a few seconds for the data to load. In this scenario, the splash screen comes up for few seconds and then I just see a blank (black) screen for another few seconds and then I see the first screen. I suspect the blank screen comes up for the time it takes to fetch data from the server. I looking for ways to solve this issue
Question
Update
This is how I'm loading the data
def self.fetch(client, &block)
client.shared.headers["username"] = App::Persistence["username"]
client.shared.headers["token"] = App::Persistence["sessionId"]
client.shared.get('categories') do |result|
if result.success?
ary = result.object
block.call(ary)
end
end
end
and to use it
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
Color.fetch(AFMotion::Client) do |data|
main_controller = ColorController.alloc.initWithData(data)
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller)
@window.rootViewController.navigationBar.barTintColor = '#DF533B'.to_color
@window.rootViewController.navigationBar.translucent = true
@window.rootViewController.navigationBar.tintColor = UIColor.whiteColor
@window.rootViewController.navigationBar.setTitleTextAttributes({
UITextAttributeTextColor => UIColor.whiteColor
})
end
@window.makeKeyAndVisible
@window.tintColor = '#DF533B'.to_color
end
Yes it can, but it should not be done. The "splash" screen is shown when you app is being loaded in memory. You can delay the remove all of this screen bij not return directly form the application:didFinishLaunchingWithOptions:
method. But doing so might get your app killed by the os because it is take to long to load.
You best option to place a view in the UIWindow
that show that your app is downloading data. This way your user see that your app is doing something. If it is possible to show some kind of progress here that would even be better.
You could even do it in the view controller where you perform the network call, just push a loading view onto the view just before you start the netwerk call. Once it is finished remove the view. This will work only if the network call is not blocking any UI updates.