Ios 使用MvvmCross和Xamarin加载a.xib
我现在正在给头发涂上焦油。我一直在尝试从插件中加载一个非常简单的视图,但不断出现不同的错误。我上次尝试时出现以下错误: 'Foundation.MonoTouchException:引发Objective-C异常。姓名: N内部一致性异常原因:-[UIViewController _loadViewFromNibNamed:bundle:]加载了“PincodeView”nib,但未设置视图出口 以下是.xib:Ios 使用MvvmCross和Xamarin加载a.xib,ios,xamarin,mvvmcross,Ios,Xamarin,Mvvmcross,我现在正在给头发涂上焦油。我一直在尝试从插件中加载一个非常简单的视图,但不断出现不同的错误。我上次尝试时出现以下错误: 'Foundation.MonoTouchException:引发Objective-C异常。姓名: N内部一致性异常原因:-[UIViewController _loadViewFromNibNamed:bundle:]加载了“PincodeView”nib,但未设置视图出口 以下是.xib: <?xml version="1.0" encoding="UTF-8" s
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" launchScreen="NO">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PincodeViewController">
<connections>
<outlet property="RootView" destination="7" id="name-outlet-7"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<viewController id="6">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="4"/>
<viewControllerLayoutGuide type="bottom" id="5"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="7">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<point key="canvasLocation" x="-407" y="-274"/>
</viewController>
</objects>
</document>
我一整天都在做这件事,但还没有更进一步。所有这些伴随着VS2017的崩溃/挂起,设计师整天都在放弃我。感谢您的帮助。好的,问题是这个。我拿错了。似乎Apple->Empty用户界面和Apple->View之间存在差异
教训是:不要使用空的用户界面,而是使用视图控制器。后者创建了一个.cs和一个.xib文件,效果很好。你能创建一个github repo吗?我会尝试用一个单独的解决方案来隔离这个问题。项目中的代码与上面文本中的代码有点不同,但问题是一样的。我已经将视图移到了故事板上,现在它显示出来了。使用VS4Mac,出现了相同的异常对于使用“添加新文件”>“查看”创建的xib。使用“添加新文件>视图控制器”时工作正常。当我创建ViewController时,未创建xib文件。有什么变化吗?
using MvvmCross.iOS.Views;
using NN.Plugin.Utils.iOS.IOC;
using NN.Plugin.Utils.ViewModels;
namespace NN.Plugin.Utils.iOS
{
public partial class PincodeViewController : MvxViewController<PincodeViewModel>
{
public PincodeViewController () : base ("PincodeView", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
}
}
}
// WARNING
//
// This file has been generated automatically by Visual Studio from the outlets and
// actions declared in your storyboard file.
// Manual changes to this file will not be maintained.
//
using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;
namespace NN.Plugin.Utils.iOS
{
[Register ("PincodeViewController")]
partial class PincodeViewController
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UIView RootView { get; set; }
void ReleaseDesignerOutlets ()
{
if (RootView != null) {
RootView.Dispose ();
RootView = null;
}
}
}
}
using MvvmCross.Core.ViewModels;
using NN.Plugin.Utils.ViewModels;
using System.Windows.Input;
using System;
namespace PluginsTester.Core.ViewModels
{
public class FirstViewModel
: MvxViewModel
{
public override void Start()
{
base.Start();
// ShowViewModel<PincodeViewModel>();
}
string hello = "Hello MvvmCross";
public string Hello
{
get { return hello; }
set { SetProperty(ref hello, value); }
}
public ICommand PinClicked
{
get => new MvxCommand(() => OpenPin());
}
private void OpenPin()
{
ShowViewModel<PincodeViewModel>();
}
}
}