我正在开发一个Xamarin IOS / monotouch项目。 一段时间以来,我一直坚持这个错误。这些是代码行
var prfc = this.Storyboard.InstantiateViewController ("testController") as testController;
if (prfc != null) {
this.PresentViewController(prfc,false,null);}
我尝试重命名viewcontroller,清理和构建解决方案,删除viewcontroller并添加一个具有其他名称的新控件 我确保所有拼写都是正确的,我有相同的Viewcontroller名称,StoryBoardID和Restoration ID。这就是我在Designer partial class
中注册我的viewcontroller的方法[Register ("testController")]
partial class testController
这是我的appdelegate.cs代码`[注册(" AppDelegate")]公共部分类AppDelegate:UIApplicationDelegate {//类级声明UIWindow窗口; public static UIStoryboard Storyboard = UIStoryboard.FromName(" MainStoryboard",null); public static UIViewController initialViewController; public override UIWindow Window {get;组; }
`[Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { // class-level declarations UIWindow window; public static UIStoryboard Storyboard = UIStoryboard.FromName ("MainStoryboard", null); public static UIViewController initialViewController; public override UIWindow Window { get; set; }
// This method is invoked when the application is about to move from active to inactive state.
// OpenGL applications should use this method to pause.
public override void OnResignActivation (UIApplication application)
{
}
// This method should be used to release shared resources and it should store the application state.
// If your application supports background exection this method is called instead of WillTerminate
// when the user quits.
public override void DidEnterBackground (UIApplication application)
{
}
// This method is called as part of the transiton from background to active state.
public override void WillEnterForeground (UIApplication application)
{
}
// This method is called when the application is about to terminate. Save data, if needed.
public override void WillTerminate (UIApplication application)
{
}
public override void FinishedLaunching (UIApplication application)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
initialViewController = Storyboard.InstantiateInitialViewController () as UIViewController;
window.RootViewController = initialViewController;
window.MakeKeyAndVisible ();
return ;
}
}`
我已尝试过各种可能性但无法解决此问题。我添加到Storyboard的每个新viewcontroller都会出现此错误。当我调用InstantiateViewController时,我得到一个null。我尝试过清洁和重建。它适用于模拟器,但不适用于设备
答案 0 :(得分:1)
@orkenstein指出了这个问题。我的目标是7.1,而是在7.0设备上进行测试