我現在試圖按照facebook的完整指南,但是當我嘗試構建時,我總是收到錯誤。Swift 3 Facebook登錄
我得到的錯誤是type of expression is ambigous without more context
在這條線LoginManager.logIn([.PublicProfile], viewController: self) { loginResult in
我已經
我已經開始與投入莢
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
,然後運行在這之後pod install
我已經將它導入到我的viewController中
import FacebookCore
import FacebookLogin
我已經加入一個UIButton到viewDidLoad
let myLoginButton = UIButton(type: .custom)
myLoginButton.backgroundColor = UIColor.darkGray
myLoginButton.frame = CGRect(x: 0, y: 0, width: 180, height: 40);
myLoginButton.center = view.center;
myLoginButton.setTitle("My Login Button", for: .normal)
然後我添加了以下功能到ViewController
@objc func loginButtonClicked() {
let loginManager = LoginManager()
LoginManager.logIn([.PublicProfile], viewController: self) { loginResult in
switch loginResult {
case .Failed(let error):
print(error)
case .Cancelled:
print("User cancelled login.")
case .Success(let grantedPermissions, let declinedPermissions, let accessToken):
print("Logged in!")
}
}
}
我什麼也沒做改變 –
替換 「.PublicProfile」 與 「.publicProfile」 –