views:

45

answers:

2

Hi, I'm new to objective-c so bare with me. I'm using the Facebook iPhone SDK found here:

http://github.com/facebook/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.

In my viewDidLoad method (i'm putting it here as I'm initialing the view with a nib) I have the following code:

  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???

thanks in advance for any hep!

A: 

many things could be wrong here. if you are using NIBs have you correctly connected up the view in interface builder?

secondly, I don't know about the facebook sdk, but have you properly included the headers? I'm assuming you will need to include a class "FBLoginButton" somewhere. This may be as an @class in your .h file, or at the top of your .m file like import "FBLoginButton.h" (or similar).

Have you tried doing it all without setting the session. Also, have you tried creating a normal button (UIButton) instead of a FBLoginButton? Does that work?

Thomas Clayson
A: 

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];
Eiko
I've realize that the problem is with accessing the images in the FBConnect.bundle. I've moved the bundle to the resources folder but it still can't find them. To test this I just made a simple call as soUIImage* image = [UIImage imageNamed:@"FBConnect.bundle/images/logout_down.png"];I'm guessing there's a step I'm missing in Xcode that needs to be done when bringing the bundle into the resource folder? This is all new to me so I'm going to keep looking...
bruin
Figured it out. Went to Get Info for the bundle, then Targets and selected my App. thanks for everyone's help!
bruin