1

SVProgressHUD在我的 swift 项目中用作框架。它在 iOS 8 中运行良好。我在我的应用程序中使用 Facebook 登录。每当我使用登录SVProgressHUD名时,应用程序都不会显示。但是当我杀死应用程序并启动SVProgressHUD时会正常工作。我已经在 info.plist 中添加了必需的键。我无法弄清楚问题所在。请任何人提供解决方案。

编辑:如果我将“登录行为”更改为 Web 和 SystemAccount。它工作正常。

环境 FBSDK:- 4.8.0 XCode:- 6.4,Swift 1.2

LoginViewController.swift

  func loginButton(loginButton: FBSDKLoginButton!,
    didCompleteWithResult
    result: FBSDKLoginManagerLoginResult!,
    error: NSError!) {

        SVProgressHUD.showWithStatus(NSLocalizedString("LOGIN_PROGRESS_MSG", comment: ""))

        if (error != nil) {
            DDLogError("FB Login error: \(error.localizedDescription)")
            SVProgressHUD.showErrorWithStatus(NSLocalizedString(error.localizedDescription, comment: ""))
        } else if result.isCancelled {
            DDLogError("FB Login cancelled")
            SVProgressHUD.showErrorWithStatus(NSLocalizedString("Login cancelled", comment: ""))
        } else {
            DDLogDebug("FB Login success")
            SVProgressHUD.showWithStatus(NSLocalizedString("FB_USER_FETCH_MSG", comment: ""))
            returnUserData()
        }
}

Appdelegate.swift

 let fbLaunch = FBSDKApplicationDelegate.sharedInstance().application(application,
            didFinishLaunchingWithOptions: launchOptions) // Added this method in didFinishLaunchingWithOptions method

也实施了

 func application(application: UIApplication,
    openURL url: NSURL,
    sourceApplication: String?,
    annotation: AnyObject?) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(
            application,
            openURL: url,
            sourceApplication: sourceApplication,
            annotation: annotation)
}

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.
    LocationManager.sharedInstance.startLocationManger()
    FBSDKAppEvents.activateApp()
    //Send device token change
    APNSManager.validateAndUpdateAPNSToken()

    //Look for APNS payload in background if we have saved any
    APNSManager.handlePendningAPNSPayloads()
}
4

2 回答 2

2

如果在主线程上执行繁重的任务,则不会显示 Svprogresshud。延迟 4 毫秒后显示加载程序将解决问题

DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(400)) {
            SVProgressHUD.show()
        }
于 2017-11-03T10:34:10.197 回答
0

从块调用时尝试在主队列中显示 SVProgressHUD

dispatch_async(dispatch_get_main_queue(), {
          SVProgressHUD.showWithStatus(NSLocalizedString("LOGIN_PROGRESS_MSG", comment: ""))

            })
于 2015-12-17T15:36:19.200 回答