简体   繁体   English

iPhone的Facebook登录按钮不呈现

[英]iphone facebook login button not rendering

I'm using the Facebook iPhone SDK . 我正在使用Facebook iPhone SDK

All I'm trying to do is display the login button given in the SDK though obviously I don't have a full understanding of views. 我要做的只是显示SDK中提供的登录按钮,尽管显然我对视图没有完全的了解。

In my viewDidLoad method (i'm putting it here as I'm initialing the view with a nib) I have the following code: 在我的viewDidLoad方法中(我用笔尖初始化视图时将其放在此处),我有以下代码:

  CGRect rect = CGRectMake(30, 350, 90, 31);
  FBLoginButton* button = [[FBLoginButton alloc] initWithFrame:rect];
  [button setSession:delegate.session];
  [self.view addSubview:button];
  [button release];

The session that I'm passing in is valid but nothing shows up. 我正在传递的会话有效,但没有任何显示。

I had a similar problem, are you sure that you included the resource bundle as well ? 我有一个类似的问题,您确定还包括资源包吗?

Its inside the framework, but in my experience, it doesn't get loaded correctly, unless you include it straight into your app as a resource. 它在框架中,但是根据我的经验,除非您将其作为资源直接包含在应用中,否则无法正确加载。 (You can still do it linked, so you don't have the same file twice) (您仍然可以链接它,因此您没有两次相同的文件)

Without the resouce bundle, the app has no graphics to design the button. 没有资源包,该应用程序将无法设计按钮。

many things could be wrong here. 许多事情在这里可能是错误的。 if you are using NIBs have you correctly connected up the view in interface builder? 如果使用的是NIB,您是否已正确连接接口构建器中的视图?

secondly, I don't know about the facebook sdk, but have you properly included the headers? 其次,我不了解facebook sdk,但是您是否正确包含了标题? I'm assuming you will need to include a class "FBLoginButton" somewhere. 我假设您需要在某个地方包含一个类“ FBLoginButton”。 This may be as an @class in your .h file, or at the top of your .m file like import "FBLoginButton.h" (or similar). 这可能是您的.h文件中的@class,也可能是.m文件顶部的部分,例如import "FBLoginButton.h" (或类似名称)。

Have you tried doing it all without setting the session. 您是否尝试过全部操作而不设置会话。 Also, have you tried creating a normal button (UIButton) instead of a FBLoginButton? 另外,您是否尝试过创建普通按钮(UIButton)而不是FBLoginButton? Does that work? 那样有用吗?

This is what I used: 这是我使用的:

FBSession *session = [FBSession sessionForApplication:myApiKey secret:myAppSecret delegate:self];
[session resume];
[session retain];

FBLoginButton *fbLoginButton = [[FBLoginButton alloc] init];
[fbLoginButton sizeToFit];
fbLoginButton.center = CGPointMake(..., ...);
[self.view addSubview:fbLoginButton];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM