[英]The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'
I am trying to use Facebook API for the 1st time on an iOS App. 我试图在iOS App上第一次使用Facebook API。 I'm trying to implement a login button like told on facebook API doc.
我正在尝试实现一个登录按钮,就像在Facebook API文档上告诉的那样。
Here is my app delegate : 这是我的应用程序代表:
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)
}
Here is my view controller: 这是我的视图控制器:
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")
}
I am getting this error The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'
on the line class ViewController: UIViewController, FBSDKLoginButtonDelegate
我收到此错误
The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'
行class ViewController: UIViewController, FBSDKLoginButtonDelegate
上的The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate'
class ViewController: UIViewController, FBSDKLoginButtonDelegate
Whereas on a project that I found on the web using exactly the same syntax, no error comes up and the project builds without any problem. 在我使用完全相同的语法在网络上找到的项目中,没有错误出现,并且该项目的构建没有任何问题。
Did anyone of you have the same problem ? 你们中有人有同样的问题吗?
尝试实现FBSDKLoginButtonDelegate所需的方法。
in the new Xcode/iOS developing format is e if we use or declared any delegate's compulsory declare the method also, just like FBSDKLoginButtonDelegate
we need to implement the delegate methods, else remove the delegate in Header 在新的Xcode / iOS开发格式中,如果我们也使用或声明任何委托的强制声明方法,则就像
FBSDKLoginButtonDelegate
一样,我们需要实现委托方法,否则请删除Header中的委托
- (void) loginButton: (FBSDKLoginButton *)loginButton
didCompleteWithResult: (FBSDKLoginManagerLoginResult *)result
error: (NSError *)error{
NSLog(@"facebook login button test");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.