Visual Studio 2013 Premium 中的 Xamarin iOS 项目

Xamarin iOS project in Visual Studio 2013 Premium

在 Visual Studio 2013 Premium 中尝试 运行 Xamarin iOS 项目时出现问题。这意味着 LoginView.xib 不在项目的包中。 我 Mac 上的 Xamarin Studio 对此没有问题。

Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle </Users/gtas/Library/Developer/CoreSimulator/Devices/215AE19B-D168-47F2-82D8-D5B40CDB46DE/data/Containers/Bundle/Application/33D2A0A9-F775-4B46-9041-E26EB53AF417/OnLeaveiOS.app> (loaded)' with name 'LoginView'

我使用以下代码将 xib 加载到支持的 class 文件中。

    public LoginView(IntPtr h): base(h)
    {
        SetupView ();
    }

    public LoginView ()
    {
        SetupView ();
    }

    public LoginView (LoginRegisterViewModel vm)
    {
        _vm = vm;
        SetupView ();
    }

    private void SetupView()
    {
        view = LoadViewFromXib ();
        view.BackgroundColor = UIColor.Clear;
        AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
        Bounds = view.Bounds;
        _intrinsicContentSize = Bounds.Size;
        TranslatesAutoresizingMaskIntoConstraints = false;
        SetupOutlets ();
        this.AddSubview (view);
    }

    private UIView LoadViewFromXib()
    {
        NSBundle bundle = NSBundle.FromClass (this.Class);
        UINib nib = UINib.FromName ("LoginView", bundle);
        return (UIView)nib.Instantiate (this, null)[0];
    }

我在编码本机 iOS 应用程序时使用这种技术分离我的 UI 组件,一切都很好。另外正如我所说,Mac Xamarin Studio 似乎对此并不在意。

我结合使用故事板文件和 XIB 组件。

来自 Xamarin 论坛的回答。 http://forums.xamarin.com/discussion/comment/111300#Comment_111300.

This is most likely https://bugzilla.xamarin.com/show_bug.cgi?id=27990. That bug has been fixed in the latest XamarinVS alpha version (3.9.530). See also the XamarinVS 3.9.530 alpha release thread: http://forums.xamarin.com/discussion/36241/alpha-release-xamarinvs-3-9-530-watchkit-bug-fixes/p1.

If you'd like to downgrade temporarily until 3.9.530 is promoted to stable, see the 3.9.483 stable release thread: http://forums.xamarin.com/discussion/35785/stable-release-xamarinvs-3-9-483-watchkit/p1