2017-04-07 6 views
-1

imageimageViewに入れました。LaunchStoreyboardに入れました。プログラムの時間をどのように遅らせることができますか?どんな助けも非常に感知できるでしょう。ここで スウィフトXcode iOSでスプラッシュ起動画面をプログラムで遅らせる方法

はここ Launch Screen Guideline from Apple

で起動画面の表示コントローラのコードは

import UIKit 
class LaunshViewController: UIViewController { 

override func viewDidLoad() { 
    super.viewDidLoad() 
self.delay(0.4) 
} 


func delay(_ delay:Double, closure:@escaping()->()) { 
    let when = DispatchTime.now() + delay 
    DispatchQueue.main.asyncAfter(deadline: when, execute: closure) 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 
} 
+0

の可能性のある重複した[iOS版:?起動画面を遅らせる方法](http://stackoverflow.com/questions/35028449/ios-how-to-delay-起動画面) –

+0

私の質問はSwift 3ですが、Obj-Cの@OlegGordiichuk –

+4

の実装方法が提案されていますが、プログラミング言語に依存することなく大丈夫です。 –

答えて

12

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     Thread.sleep(forTimeInterval: 3.0) 
     // Override point for customization after application launch. 
     return true 
    } 
+1

それは働いている!ありがとう@ジャック。 –

1

のViewController作成AppDelegateクラスのコードの1行を入れていますNSTimerを使用してdeを検出する寝る時間。タイマーが終了すると、最初のUIViewcontrollerをプッシュします。 viewDidLoadメソッドで

..

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(fireMethod) userInfo:nil repeats:NO]; 


-(void)fireMethod 
{ 
// push view controller here.. 
} 
関連する問題