I\'m doing the scrumptios facebook developer tutorial for the 3.1 iOS SDK. I\'ve managed to display my profile name from facebook, however the FBProfilePictureView wont show
Adding the [FBProfilePictureView class];
as the first line in the app delegate method of didFinishLaunching seems kinda hacky to me.
Check out the HelloFacebookSample inside the SDK. Here is the 4 line comment:
// If you have not added the -ObjC linker flag, you may need to uncomment the following line because
// Nib files require the type to have been loaded before they can do the wireup successfully.
// http://stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime
// [FBProfilePictureView class];
I tried adding the -ObjC
flag and it worked fine.
As documented in the facebook webpages you need to put the [FBProfilePictureView class]; as the first line in the app delegate method of didFinishLaunching. (Note their sample code does not have this but still works, in my case it will not work without it.
I created a UIView object sized it up and then selected the class from UIView to FBProfilePictureView. This will disconnect any connection between your program and IB so you need to reconnect again, the error in which you are not able to see the picture is due to the object not being wired up to an IBOutlet item. I am not sure if a cut and paste will work, maybe it will, but I created the object from UIView and just changed the class manually through IB.
Without the [FBProfilePictureView class]; it will give you an error.
If done correctly, if you view the XIB - in the object window/list you should see "Profile Picture View"along with Button and Label instead of FBProfilePictureView. The profile pic from facebook should show.
To resolve this, add this as the first line in the app delegate's application:didFinishLaunchingWithOptions: method:
[FBProfilePictureView class];
They(fb developer forum) said paste that in your app delegate didLunch method like that
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[FBProfilePictureView class];
// Create a LoginUIViewController instance where the login button will be
LoginUIViewController *loginUIViewController = [[LoginUIViewController alloc] init];
// Set loginUIViewController as root view controller
[[self window] setRootViewController:loginUIViewController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
just replace
[FBProfilePictureView class];
with these commented lines it will work
// Override point for customization after application launch.
// Load the FBProfilePictureView
// You can find more information about why you need to add this line of code in our troubleshooting guide
// https://developers.facebook.com/docs/ios/troubleshooting#objc
[FBProfilePictureView class];
it will work magically :)
Classes that use categories to extend existing classes are not loaded automatically. Classes that are used from the Xcode interface builder aren't loaded automatically, for example when you add a FBLoginView to your interface by drawing a view in your .xib file and then classing it as FBLoginView from the interface builder UI.
class
helps to create a pointer to the FBProfilePictureView.
I have the same problem. My solution is to uncheck the "Use autolayout" option in "File Inspector" of the xib file. To open the "File Inspector", press cmd+option+1 after opening the xib file.
Edit 1: Just find another solution.
Try to set a width constraint and height constraint to the profile picture view. I find this tutorial is useful.