ios - "Unknown class ABC in Interface Builder file"和 "This class is not key-value compliant..."

标签 ios xcode xamarin.ios xamarin

我试图通过 XCode 中的用户定义的运行时属性部分设置我的 ViewController 的一些属性,但遇到了一些问题。

首先,当 ViewController 被实例化时(通过我 Storyboard中的一个 segue),我在输出窗口中得到以下内容:

Unknown class FlyoutViewController in Interface Builder file.

其次,我收到以下错误:

Objective-C exception thrown. Name: NSUnknownKeyException Reason: [UIViewController 0x7fdc1450> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key topViewControllerStoryboardId.

我已阅读 troubleshooting guide没有任何帮助。唯一让我印象深刻的部分是:

the types containing the above code must be a subclass of NSObject

虽然我看不出在子类化 UIViewController 时这怎么可能?

这里是我代码的相关部分供引用:

[Register("FlyoutViewController")]
public partial class FlyoutViewController : UIViewController, IUIViewControllerContextTransitioning, IUIViewControllerTransitionCoordinator, IUIViewControllerTransitionCoordinatorContext
{
    public FlyoutViewController(IntPtr handle) : base(handle) 
    {
       // Stuff here
    }

    [Export("topViewControllerStoryboardId:", ArgumentSemantic.Retain)]
    public NSString TopViewControllerStoryboardId { get; set; }

    [Export("underLeftViewControllerStoryboardId:", ArgumentSemantic.Retain)]
    public NSString UnderLeftViewControllerStoryboardId { get; set; }

    [Export("underRightViewControllerStoryboardId:", ArgumentSemantic.Retain)]
    public NSString UnderRightViewControllerStoryboardId { get; set; }

    // More stuff...
}

在 Storyboard的 ViewController 属性中,我已将类设置为 FlyoutViewController 并添加了以下运行时属性:

topViewControllerStoryboardId | String | FeedNavigationController
underLeftViewControllerStoryboardId | String | MenuViewController

谁能告诉我哪里出了问题?

提前致谢。

最佳答案

问题是您正在实现两个至少有两个相同成员的接口(interface): IUIViewControllerTransitionCoordinatorContextIUIViewControllerContextTransitioning

这是我得到的输出,先于“...这个类不是关键 topViewControllerStoryboardId 的键值编码兼容”消息:

Cannot register more than one interface method for the method 'XcodeAttrController.MyController.get_ContainerView' (which is implementing 'MonoTouch.UIKit.IUIViewControllerTransitionCoordinatorContext.get_ContainerView' and 'MonoTouch.UIKit.IUIViewControllerContextTransitioning.get_ContainerView').

请注意,我的 Controller 在这里命名为“MyController”:)。

在另一个对象中实现其中一个接口(interface),然后改用那个接口(interface)。

关于ios - "Unknown class ABC in Interface Builder file"和 "This class is not key-value compliant...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22184614/

相关文章:

android - 如何在 Android 和 IOS 的 Flutter 中获取设备 ID

ios - 主 VC 中的工具栏和 Modal VC 中的工具栏不会显示相同的按钮

ios - 每次在 UIImagePickerController() 的 dismiss() 之后调用 viewDidLoad()

ios - 如何使用自动布局设置按钮宽度并针对 iPhone 6 plus 进行调整?

xcode - Flutter:命令 PhaseScriptExecution 失败,退出代码非零

objective-c - 从 ObjectiveC 类引用 UIViewController

xamarin - 将容器 View 与 Xamarin 和 MVVMCross 结合使用

ios - 带有自定义 View 的 Xamarin.Forms 弹出对话框

ios - ENABLE_BITCODE 问题。 Xcode 7 归档问题

ios - UILabel 文本截尾点颜色