简体   繁体   English

在情节提要中创建FBProfilePictureView

[英]Creating a FBProfilePictureView in Storyboard

I created a UIView inside the main view of a view controller using the storyboard editor and changed its class to FBProfilePictureView . 我使用情节FBProfilePictureView编辑器在视图控制器的主视图内创建了UIView ,并将其类更改为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. 但是,当我在代码中引用userImage对象时,它将自己报告为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: 虽然我没有看到FB文档中提到的错误,但添加了:

[FBProfilePictureView class];

To applicationDidFinishLaunching did the trick. 到applicationDidFinishLaunching做到了。 Presumably some runtime magic going on. 大概正在发生一些运行时魔术。

I wouldn't rely on [userImage class] for anything other than calling class methods. 除了调用类方法之外,我不会依赖[userImage class] If you need to ensure userImage is the correct type, use [userImage isKindOfClass:[FBProfilePictureView class]] . 如果需要确保userImage是正确的类型,请使用[userImage isKindOfClass:[FBProfilePictureView class]] It will let you know if you can treat the object as a FBProfilePictureView. 它会让您知道是否可以将对象视为FBProfilePictureView。

A more elegant way to resolve this might be adding the -ObjC linker flag instead of doing this "runtime magic" stuff. 解决此问题的一种更优雅的方法可能是添加-ObjC链接器标志,而不是执行此“运行时魔术”操作。 Here you can find instructions on how to add the flag! 在这里,您可以找到有关如何添加标志的说明!

See the SDK documentation , which says: 请参阅SDK文档 ,其中说:

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 它提到了FBLoginView,但是根据对这个问题的回答,它也适用于FBProfilePictureView: FBProfilePictureView对象不会显示图像

Hope this helps. 希望这可以帮助。

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

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