C# Xamarin.iOS:启动后黑屏,无情节提要
我不想在我的Xamarin.iOS应用程序中使用情节提要,因此我做了以下操作: 1-删除情节提要文件 2-将plist.info文件应用程序>主界面更新为无值 3-将以下代码添加到C# Xamarin.iOS:启动后黑屏,无情节提要,c#,ios,xamarin,C#,Ios,Xamarin,我不想在我的Xamarin.iOS应用程序中使用情节提要,因此我做了以下操作: 1-删除情节提要文件 2-将plist.info文件应用程序>主界面更新为无值 3-将以下代码添加到AppDelegate文件中 [Export ("application:didFinishLaunchingWithOptions:")] public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) {
AppDelegate
文件中
[Export ("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// create a new window instance based on the screen size
Window = new UIWindow(UIScreen.MainScreen.Bounds);
var controller = new UIViewController();
controller.View.BackgroundColor = UIColor.LightGray;
controller.Title = "My Controller";
var navController = new UINavigationController(controller);
Window.RootViewController = navController;
// make the window visible
Window.MakeKeyAndVisible();
return true;
}
但这样做后,我收到了一个黑屏上的模拟器后,发射屏幕完成。即使是全新的项目也会出现这种情况。我上传了一个带有这些步骤和问题的示例新项目
我使用的是Visual Studio 2019-Xamarion.iOS 11.8.3-XCode 11.3
我最近使用Visual Studio 2015时没有任何问题,我认为这个问题只发生在Visual Studio 2019上。不幸的是,目前我没有Visual Studio 2015可供试用。从iOS 13开始,负责设置应用程序的场景,将代码从AppDelegate
移动到SceneDelegate
:
[Export ("scene:willConnectToSession:options:")]
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
UIWindowScene myScene = scene as UIWindowScene;
Window = new UIWindow(myScene);
UIViewController controller = new UIViewController();
controller.View.BackgroundColor = UIColor.LightGray;
controller.Title = "My Controller";
UINavigationController navigationMain = new UINavigationController(controller);
Window.RootViewController = navigationMain;
Window.MakeKeyAndVisible();
}
请参阅:从iOS 13开始,负责设置应用程序的场景,将代码从AppDelegate
移动到SceneDelegate
:
[Export ("scene:willConnectToSession:options:")]
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
UIWindowScene myScene = scene as UIWindowScene;
Window = new UIWindow(myScene);
UIViewController controller = new UIViewController();
controller.View.BackgroundColor = UIColor.LightGray;
controller.Title = "My Controller";
UINavigationController navigationMain = new UINavigationController(controller);
Window.RootViewController = navigationMain;
Window.MakeKeyAndVisible();
}
参考:及