我正在尝试让我的主屏幕正常工作,但在尝试调试时出现以下错误:
Cannot convert 'projectI.HomeScreen' expression to type 'MonoTouch.UIKit.UIViewController' (CS1503)
我看了一个类似的问题,但这对我不起作用。谷歌搜索也没有太大帮助。
我尝试重新创建项目,但在尝试调试时出现了同样的错误。
该错误发生在我的 AppDelegate.cs 文件上,如下所示:
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// create a new window instance based on the screen size
this.window = new UIWindow (UIScreen.MainScreen.Bounds);
// Create a new root view controller
UINavigationController rootNavController = new UINavigationController ();
// Set the homescreen
HomeScreen homeScreen = new HomeScreen ();
rootNavController.PushViewController (homeScreen, false);
// make the window visible
this.window.RootViewController = rootNavController;
this.window.MakeKeyAndVisible ();
return true;
}
}
错误发生在这一行:
rootNavController.PushViewController (homeScreen, false);
HomeScreen.cs 看起来像这样:
public partial class HomeScreen : UIViewController
{
public HomeScreen () : base ("HomeScreen", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
}
}
我不知道它为什么这样做,当我遵循 Xamarin 的指南时它工作得很好。
非常感谢任何帮助或领导。