简体   繁体   中英

Xamarin iOS project in Visual Studio 2013 Premium

Problem when trying to run a Xamarin iOS project in Visual Studio 2013 Premium. It implies that the LoginView.xib is not in project's bundle. Xamarin Studio on my Mac has no problem with this.

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'

I load the xib in the backed class file with the following code.

    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];
    }

I separate my UI components using this technique when coding native iOS apps and everything works great. Also as I said, Mac Xamarin Studio doesn't seem to bother about it.

I use a combination of Storyboard file and XIB components.

From Xamarin forum answer. 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

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