简体   繁体   English

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. 编辑#3:我以某种方式错过10次第二次控制台消息,这让我感到困惑。 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. 我需要将“ -all_load -ObjC”设置为链接器标志,但我不知道为什么它还不是那样。 See "Unknown class <MyClass> in Interface Builder file" error at runtime 在运行时,请参阅“ Interface Builder文件中的未知类<MyClass>”错误

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. 我试图在我的情节FBLoginView使用UIView的子类FBLoginView (Facebook SDK框架的一部分),并在其视图的视图控制器的viewDidLoad中为其设置属性。 This is what I have: 这就是我所拥有的: IB和代码

The UIView (grey box) shown has its class set to FBLoginView , as you can see. 如您FBLoginView ,所示的UIView(灰色框)的类设置为FBLoginView It's linked to the property loginView in my view controller .m on the right. 它链接到右侧视图控制器.m中的属性loginView

In viewDidLoad , it does _loginView.readPermissions = @[@"user_friends"] , which causes the program to crash. viewDidLoad ,它执行_loginView.readPermissions = @[@"user_friends"] ,从而导致程序崩溃。 Edit #2: The log says: 编辑#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 . 我设置了一个断点, loginView是一个UIView ,而不是FBLoginView This doesn't make sense; 这没有道理; I already changed it to FBLoginView in Interface Builder. 我已经在Interface Builder FBLoginView其更改为FBLoginView How do I fix this? 我该如何解决?

Edit: Here is the connections inspector for the view controller in IB: 编辑:这是IB中视图控制器的连接检查器: 在此处输入图片说明

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 (eg compile sources). 确保将FBLoginView.m声明为当前的构建目标成员(例如,编译源)。 To do that, select FBLoginView.m in Project Navigator, see "Target Membership" section in the File Inspector as attached screenshot(deleted). 为此,请在Project Navigator中选择FBLoginView.m ,请参阅文件检查器中的“目标成员身份”部分,该FBLoginView.m为附带的屏幕截图(已删除)。

Edit: 编辑:

You should read the documentation :) 您应该阅读文档 :)
See the bottom of "Adding the login UI control" section. 请参阅“添加登录UI控件”部分的底部。

You must add [FBLoginView class] in - application:didFinishLaunchingWithOptions: AppDelegate method OR add the -ObjC flag to your linker options. 您必须在[FBLoginView class] - application:didFinishLaunchingWithOptions: AppDelegate方法中添加[FBLoginView class] ,或将-ObjC标志-ObjC到链接器选项中。

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

相关问题 界面构建器中是否可以为常规UIView设置图像? - is there an option in interface builder to set an image for a regular UIView? 具有界面生成器视图的UIView背景渐变 - UIView Background Gradient With Interface Builder View 在Interface Builder上,将UILabel连接到自定义UIView IBOutlet - On Interface Builder connect UILabel to custom UIView IBOutlet 如何在Interface Builder中将UITableViewCell的内容视图转换为普通的UIView? - How to convert a UITableViewCell's content view to a normal UIView in Interface Builder? 如何在界面生成器中查看很高的uiview? - how to view very tall height uiview in interface builder? 使用Interface Builder添加UIView,然后删除,然后添加到另一个视图 - Add a UIView using Interface Builder, remove, then add to another view 未在模拟器中创建的自定义UIView故事板类,在界面生成器中显示 - Custom UIView storyboard class not created in simulator, shows up in interface builder Interface Builder - 如何创建具有许多子视图的自定义UIView - Interface Builder - How to create a custom UIView with many subviews 在界面构建器中添加的自定义UIView不会加载xib - Custom UIView added in the interface builder does not load the xib 如何使用故事板在界面构建器中连接自定义UIView? - How to connect custom UIView in interface builder using storyboards?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM