Interface Builder將自定義視圖分配為常規UIView

[英]Interface Builder is allocating a custom view as a regular UIView

Edit #3: I somehow missed a second console message the 10 times I ran this, keeping me puzzled about this. It's a known problem that's been solved. I need "-all_load -ObjC" set as a linker flag, and I don't know why it wasn't already like that. See "Unknown class <MyClass> in Interface Builder file" error at runtime

編輯#3:我以某種方式錯過了第二次控制台消息10次我跑了這個,讓我對此感到困惑。這是一個已經解決的已知問題。我需要將“-all_load -ObjC”設置為鏈接器標志,我不知道為什么它不是那樣的。請參閱運行時“Interface Builder文件中的未知類 ”錯誤

I'm trying to use an FBLoginView (part of the Facebook SDK framework), a subclass of UIView, in my storyboard and set a property on it in viewDidLoad in the view controller for its superview. This is what I have: IB and code

我正在嘗試在我的故事板中使用FBLoginView(Facebook SDK框架的一部分),UIView的子類,並在視圖控制器的viewDidLoad中為其superview設置一個屬性。這就是我所擁有的:

The UIView (grey box) shown has its class set to FBLoginView, as you can see. It's linked to the property loginView in my view controller .m on the right.


In viewDidLoad, it does _loginView.readPermissions = @[@"user_friends"], which causes the program to crash. Edit #2: The log says:

在viewDidLoad中,它執行_loginView.readPermissions = @ [@“user_friends”],這會導致程序崩潰。編輯#2:日志說:

App became active.
Unknown class FBLoginView in Interface Builder file.
-[UIView setReadPermissions:]: unrecognized selector sent to instance 0x10c120b90

I set a breakpoint, and loginView is a UIView, not an FBLoginView. This doesn't make sense; I already changed it to FBLoginView in Interface Builder. How do I fix this?

我設置了一個斷點,loginView是一個UIView,而不是FBLoginView。這沒有意義;我已經在Interface Builder中將其更改為FBLoginView。我該如何解決?

Edit: Here is the connections inspector for the view controller in IB: enter image description here


2 个解决方案



Some things to try:


  • Duplicate your FBLoginView class with a different name and try that.
  • 使用其他名稱復制FBLoginView類並嘗試使用。

  • Double check the spelling of your FBLoginView class name - check the file names for your .m and .h, and then check the interface/implemenation in the actual files to make sure it's capitalized correctly.
  • 仔細檢查FBLoginView類名的拼寫 - 檢查.m和.h的文件名,然后檢查實際文件中的接口/實現,以確保它的大小寫正確。



Ensure FBLoginView.m is declared as your current build target member (e.g. compile sources). To do that, select FBLoginView.m in Project Navigator, see "Target Membership" section in the File Inspector as attached screenshot(deleted).

確保將FBLoginView.m聲明為您當前的構建目標成員(例如編譯源)。為此,請在Project Navigator中選擇FBLoginView.m,請參閱文件檢查器中的“目標成員資格”部分作為附加屏幕截圖(已刪除)。


You should read the documentation :)
See the bottom of "Adding the login UI control" section.


You must add [FBLoginView class] in - application:didFinishLaunchingWithOptions: AppDelegate method OR add the -ObjC flag to your linker options.

您必須在 - application:didFinishLaunchingWithOptions:AppDelegate方法中添加[FBLoginView類]或將-ObjC標志添加到鏈接器選項。



  © 2014-2022 联系我们: