[英]Creating a FBProfilePictureView in Storyboard
我使用情節FBProfilePictureView
編輯器在視圖控制器的主視圖內創建了UIView
,並將其類更改為FBProfilePictureView
。
我創建了一個出口:
@property (weak, nonatomic) IBOutlet FBProfilePictureView *userImage;
但是,當我在代碼中引用userImage
對象時,它將自己報告為UIView。
NSLog(@"userImage class: %@", [userImage class]);
產生:
2012-08-28 17:52:22.196 FBTestApp[6230:707] userImage class: UIView
我想念什么?
雖然我沒有看到FB文檔中提到的錯誤,但添加了:
[FBProfilePictureView class];
到applicationDidFinishLaunching做到了。 大概正在發生一些運行時魔術。
除了調用類方法之外,我不會依賴[userImage class]
。 如果需要確保userImage
是正確的類型,請使用[userImage isKindOfClass:[FBProfilePictureView class]]
。 它會讓您知道是否可以將對象視為FBProfilePictureView。
解決此問題的一種更優雅的方法可能是添加-ObjC鏈接器標志,而不是執行此“運行時魔術”操作。 在這里,您可以找到有關如何添加標志的說明!
請參閱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.
它提到了FBLoginView,但是根據對這個問題的回答,它也適用於FBProfilePictureView: FBProfilePictureView對象不會顯示圖像
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.