简体   繁体   中英

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

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和代码

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:

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?

Edit: Here is the connections inspector for the view controller in IB: 在此处输入图片说明

Some things to try:

  • Duplicate your FBLoginView class with a different name and try that.
  • 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.

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

Edit:

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.

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.

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