[英]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: 这就是我所拥有的:
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: 一些尝试:
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.