[英]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加載到支持的類文件中。
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組件。
來自Xamarin論壇的答案。 http://forums.xamarin.com/discussion/comment/111300#Comment_111300 。
這很可能是https://bugzilla.xamarin.com/show_bug.cgi?id=27990 。 該錯誤已在最新的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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.