【问题标题】:Xamarin iOS project in Visual Studio 2013 PremiumVisual Studio 2013 Premium 中的 Xamarin iOS 项目
【发布时间】:2015-04-02 02:32:49
【问题描述】:

尝试在 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 加载到支持的类文件中。

    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 似乎并不在意它。

我使用 Storyboard 文件和 XIB 组件的组合。

【问题讨论】:

    标签: c# ios visual-studio-2013 xamarin.ios xamarin-studio


    【解决方案1】:

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

    这很有可能 https://bugzilla.xamarin.com/show_bug.cgi?id=27990。那个bug已经 在最新的 XamarinVS alpha 版本 (3.9.530) 中修复。另见 XamarinVS 3.9.530 alpha 发布线程: http://forums.xamarin.com/discussion/36241/alpha-release-xamarinvs-3-9-530-watchkit-bug-fixes/p1.

    如果您想暂时降级,直到 3.9.530 升级为 稳定,请参阅 3.9.483 稳定发布线程: http://forums.xamarin.com/discussion/35785/stable-release-xamarinvs-3-9-483-watchkit/p1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-28
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 2017-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多