I created a UIView
inside the main view of a view controller using the storyboard editor and changed its class to FBProfilePictureView
.
I created an outlet:
@property (weak, nonatomic) IBOutlet FBProfilePictureView *userImage;
However, when I refer to the userImage
object in code it reports itself as a UIView.
NSLog(@"userImage class: %@", [userImage class]);
Produces:
2012-08-28 17:52:22.196 FBTestApp[6230:707] userImage class: UIView
What am I missing?
While I didn't see the error mentioned in the FB docs , adding:
[FBProfilePictureView class];
To applicationDidFinishLaunching did the trick. Presumably some runtime magic going on.
I wouldn't rely on [userImage class]
for anything other than calling class methods. If you need to ensure userImage
is the correct type, use [userImage isKindOfClass:[FBProfilePictureView class]]
. It will let you know if you can treat the object as a FBProfilePictureView.
A more elegant way to resolve this might be adding the -ObjC linker flag instead of doing this "runtime magic" stuff. Here you can find instructions on how to add the flag!
See the SDK documentation , which says:
Note: If you've added the -ObjC flag to your linker options, then you don't have to add this code. Adding that flag causes the linker to load all the object files in the Facebook SDK, including the FBLoginView class. If you want to know more about what the -ObjC flag does, you can check out our troubleshooting guide.
It mentioned the FBLoginView, but according to the answer to this question, it also works for FBProfilePictureView: FBProfilePictureView object wont show image
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.