2017-06-18 15 views
-1

私はプログラミングに慣れていないとして、アプリケーションを作成しようとしています。今私の問題は、私がシミュレータを起動すると、アプリが表示されず、黒と電池/時間の列が上に表示されます。私は、シミュレータのリセット、プログラムのクリーニング、他の会話からの多くのものを試しましたが、何も働かなかった。何が問題なの?シミュレータが黒くなる

私はそれを理解する必要があるコーディングラインを挿入できます。

のViewController:

import UIKit 
import GoogleSignIn 
import Firebase 


@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { 


func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) { 

} 

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { 

} 
var window: UIWindow? 







func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:[NSObject: AnyObject]?) -> Bool { 
FIRApp.configure() 

self.window = UIWindow(frame:UIScreen.main.bounds) 
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
var ViewController: ViewController = mainStoryboard.instantiateViewController(withIdentifier: "ExampleController") as! ViewController 

self.window?.rootViewController = ViewController 

self.window?.makeKeyAndVisible() 


var configureError: NSError? 
GGLContext.sharedInstance().configureWithError(&configureError) 
assert(configureError == nil, "Error configuring Google services: \(configureError)") 

GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID" 
GIDSignIn.sharedInstance().delegate = self 




GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID 




// Initialize sign-in 
return true 





    func application(_ application: UIApplication, 
        open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 
     return GIDSignIn.sharedInstance().handle(url, 
               sourceApplication: sourceApplication, 
               annotation: annotation) 

    } 
    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, 
       withError error: Error!) { 
     if let error = error { 
      print("\(error.localizedDescription)") 
      // [START_EXCLUDE silent] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), object: nil, userInfo: nil) 
      // [END_EXCLUDE] 
     } else { 
      // Perform any operations on signed in user here. 
      let userId = user.userID     // For client-side use only! 
      let idToken = user.authentication.idToken // Safe to send to the server 
      let fullName = user.profile.name 
      let givenName = user.profile.givenName 
      let familyName = user.profile.familyName 
      let email = user.profile.email 
      // [START_EXCLUDE] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), 
       object: nil, 
       userInfo: ["statusText": "Signed in user:\n\(fullName)"]) 
      // [END_EXCLUDE] 
     } 

     func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, 
        withError error: Error!) { 
      // Perform any operations when the user disconnects from app here. 
      // [START_EXCLUDE] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), 
       object: nil, 
       userInfo: ["statusText": "User has disconnected."]) 
      // [END_EXCLUDE] 


    } 

} 

絵コンテ:

import UIKit 
import GoogleSignIn 
import Firebase 


@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { 


func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) { 

} 

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { 

} 
var window: UIWindow? 







func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:[NSObject: AnyObject]?) -> Bool { 
FIRApp.configure() 
return true 
self.window = UIWindow(frame:UIScreen.main.bounds) 
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
var ViewController: ViewController = mainStoryboard.instantiateViewController(withIdentifier: "ExampleController") as! ViewController 

self.window?.rootViewController = ViewController 

self.window?.makeKeyAndVisible() 

return true 
var configureError: NSError? 
GGLContext.sharedInstance().configureWithError(&configureError) 
assert(configureError == nil, "Error configuring Google services: \(configureError)") 

GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID" 
GIDSignIn.sharedInstance().delegate = self 

return true 





GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID 




// Initialize sign-in 

return true 





    func application(_ application: UIApplication, 
        open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 
     return GIDSignIn.sharedInstance().handle(url, 
               sourceApplication: sourceApplication, 
               annotation: annotation) 

    } 
    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, 
       withError error: Error!) { 
     if let error = error { 
      print("\(error.localizedDescription)") 
      // [START_EXCLUDE silent] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), object: nil, userInfo: nil) 
      // [END_EXCLUDE] 
     } else { 
      // Perform any operations on signed in user here. 
      let userId = user.userID     // For client-side use only! 
      let idToken = user.authentication.idToken // Safe to send to the server 
      let fullName = user.profile.name 
      let givenName = user.profile.givenName 
      let familyName = user.profile.familyName 
      let email = user.profile.email 
      // [START_EXCLUDE] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), 
       object: nil, 
       userInfo: ["statusText": "Signed in user:\n\(fullName)"]) 
      // [END_EXCLUDE] 
     } 

     func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, 
        withError error: Error!) { 
      // Perform any operations when the user disconnects from app here. 
      // [START_EXCLUDE] 
      NotificationCenter.default.post(
       name: Notification.Name(rawValue: "ToggleAuthUINotification"), 
       object: nil, 
       userInfo: ["statusText": "User has disconnected."]) 
      // [END_EXCLUDE] 


    } 

} 

func applicationWillResignActive(_ application: UIApplication) { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
} 

func applicationDidEnterBackground(_ application: UIApplication) { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

func applicationWillEnterForeground(_ application: UIApplication) { 
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
} 

func applicationDidBecomeActive(_ application: UIApplication) { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 

func applicationWillTerminate(_ application: UIApplication) { 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 


}} 
+0

コードを投稿してください。 – Losiowaty

+0

どのようなコードが必要ですか? –

+0

あなたの最初のビューコントローラは良いスタートです。さらに、 'storyboard' /' xib'で行ったかもしれない設定があります。 – Losiowaty

答えて

0

あなたの問題はあなたのAppDelegateにあるようです。 application:didFinishLaunchingWithOptions:メソッドに複数のreturnステートメントがあるようです。実行は最初のステートメントの後の部分には届きません。したがって、ビューコントローラのインスタンス化には到達しません。最後のものを除いてすべてのreturnステートメントを削除するだけで、すべてが機能するはずです。

+0

私はこれを試しましたが、うまくいきませんでした。私は質問でappDelegateを更新しました。そこには何か忘れていますか? –

+0

これはなぜですか? 'self.window = UIWindow(frame:UIScreen.main.bounds)'?ウィンドウはシステムによって初期化されます。 – Losiowaty

+0

これは、シミュレータが黒であれば、別の会話が助け​​てくれると言われましたが、私にとっては助けにならなかったかもしれません。しかし、私はそれを挿入する前に問題が発生しました。 –

関連する問題