0
我執行GoogleSignInDelegate爲authentication.In,我已經實現了GoogleSignIn代表method.I要添加UIActivityIndicator在它與同現有implementation.Any想法的方法之一哪有我這樣做?調用默認的委託執行
我執行GoogleSignInDelegate爲authentication.In,我已經實現了GoogleSignIn代表method.I要添加UIActivityIndicator在它與同現有implementation.Any想法的方法之一哪有我這樣做?調用默認的委託執行
在我的註冊控制器中,我實現了委託的方法。
// MARK: GIDSignInDelegates.
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
showProgressBarIndicator()
if (error == nil) {
let params = [
"access_token" : user.authentication.accessToken,
"email" : user.profile.email,
"name" : user.profile.name,
"photoUrl" : user.profile.imageURLWithDimension(100).absoluteString,
"profile_url" : user.profile.imageURLWithDimension(100).absoluteString,
"provider" : Provider.GooglePlus.rawValue,
"provider_id" : user.authentication.clientID
]
AFWrapper.requestPOSTURL(BaseUrl + ApiMethod.SignUp.rawValue, params: params,
success: {(JSONResponse) -> Void in
self.saveDataToDisk(JSONResponse)
},
failure: { (error) -> Void in
dispatch_async(dispatch_get_main_queue(), {
self.removeProgressBarIndicator()
JLToast.makeText("Connection Error!").show()
})
}
)
} else {
dispatch_async(dispatch_get_main_queue(), {
self.removeProgressBarIndicator()
JLToast.makeText("Error in getting data from Google!").show()
})
}
}
和IM我的基本控制器我有以下方法。
func showProgressBarIndicator() {
container.frame = self.view.frame
container.center = view.center
container.backgroundColor = UIColor(colorLiteralRed: 255.0, green: 255.0, blue: 255.0, alpha: 0.7)
let loadingView: UIView = UIView()
loadingView.frame = CGRectMake(0, 0, 80, 80)
loadingView.center = view.center
loadingView.backgroundColor = UIColor(colorLiteralRed: 0.0, green: 0.0, blue: 0.0, alpha: 0.7)
loadingView.clipsToBounds = true
loadingView.layer.cornerRadius = 10
let activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
activityIndicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
activityIndicator.activityIndicatorViewStyle =
UIActivityIndicatorViewStyle.WhiteLarge
activityIndicator.center = CGPointMake(loadingView.frame.size.width/2,
loadingView.frame.size.height/2);
activityIndicator.startAnimating()
loadingView.addSubview(activityIndicator)
container.addSubview(loadingView)
self.view.addSubview(container)
}
func removeProgressBarIndicator() {
if !container.isDescendantOfView(self.view) {
self.container.removeFromSuperview()
}
}
可以initializee UIActivityIndicator在viewDidLoad中()活性的方法,在任何GoogleSignInDeleggate的方法的動畫。 –
@SachinSaxena - 但後來默認實現的方法沒有被調用,這是通過谷歌登錄framework.How我可以執行該委託方法的兩個實現嗎? – nik
我在下面附上了一個答案。我在我的應用程序中已經實現了。 –