In my Iphone app need to display a splash screen (displays company logo and some info) for 2-3 seconds before load the first page.
Also the app needs to decide which page should load as the first page in here (according the 'initial setup completion' level by the user).
I am using 'Swift' as the programing language and 'Universal StoryBoard' to design interfaces...
I have seleted the Main.storyboard as the Launch Screen File. In the ViewController class have implemented following logic
override func viewDidAppear(animated: Bool) {
NSLog("_______Before sleep_______")
sleep(2)
NSLog("_______After sleep________")
self.controllNavigation()
}
func controllNavigation() -> Void {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var nextViewController
if (Condition1)
{
nextViewController = storyBoard.instantiateViewControllerWithIdentifier("MainMenu") as! MainMenuViewController
}
else
{
nextViewController = storyBoard.instantiateViewControllerWithIdentifier("UserSetup") as! UserSetupViewController
}
self.presentViewController(nextViewController, animated: true, completion: nil)
}
All works ok but While waiting with sleep(2), refresh page sort of a thing happens. I am not sure if this is the best way to do. Like to hear ideas. Thanks
Aucun commentaire:
Enregistrer un commentaire