我想在iOS应用上第一次使用Facebook API。我试图实现一个登录按钮,就像在facebook API文档中告诉的一样。'ViewController'类型不符合协议'FBSDKLoginButtonDelegate'
这里是我的应用程序的委托:
import UIKit
import FBSDKCoreKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//return true
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool
{
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
这里是我的视图控制器:
import UIKit
import FBSDKCoreKit
import FBSDKLoginKit
class ViewController: UIViewController, FBSDKLoginButtonDelegate
{
// @IBOutlet weak var testLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
if (FBSDKAccessToken.currentAccessToken() == nil)
{
NSLog("Not logged in..")
}
else
{
NSLog("Logged in..")
}
//Création et positionnement du bouton de login Facebook
let loginButton:FBSDKLoginButton=FBSDKLoginButton()
loginButton.center=self.view.center
self.view.addSubview(loginButton)
loginButton.delegate=self
loginButton.readPermissions=["public_profile", "email", "user_fiends"]
NSLog("UI OK")
}
我收到此错误The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'
上线class ViewController: UIViewController, FBSDKLoginButtonDelegate
而上一个项目,我在网上找到了完全相同的语法,没有出现错误,并且项目没有任何问题。
你们有没有人有同样的问题?
你的问题是好的,如果有任何面对这个问题,你的问题对美国有用 –