【发布时间】:2020-08-25 19:53:43
【问题描述】:
因此,在 android 模拟器上测试我的应用程序时,我没有任何问题,但是当我在 iOS 上测试我的应用程序时,我得到 Xamarin 的启动蓝屏,然后应用程序关闭,我被带到模拟器上的所有应用程序页面(但它的行为就像它仍在运行,因为您仍然在 Visual Studio 上看到显示应用程序运行时间的红色方块)。
所以我没有收到任何错误消息,所以我不确定如何找到问题,因为我是移动开发新手。
有什么想法吗?非常感谢!
App.xaml
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Calculette.App">
<Application.Resources>
</Application.Resources>
</Application>
App.xaml.cs
using Calculette.Database;
using System;
using System.IO;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
//[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace Calculette
{
public partial class App : Application
{
static CalculetteDatabase database;
public static CalculetteDatabase Database
{
get
{
if (database == null)
{
database = new CalculetteDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Calculette.db3"));
}
return database;
}
}
public App()
{
InitializeComponent();
//MainPage = new MainPage();
// Pour pouvoir faire apparaitre la toolbaritems
MainPage = new NavigationPage(new MainPage());
((NavigationPage)MainPage).BarBackgroundColor = Color.FromHex("#008A00");
((NavigationPage)MainPage).BarTextColor = Color.FromHex("#FFFFFF");
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
适用于 iOS 的 AppDelegate.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace Calculette.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// 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)
{
Xamarin.Forms.Forms.SetFlags(new string[] { "Expander_Experimental", "SwipeView_Experimental" });
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
}
iOS 的 Main.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace Calculette.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
}
加载应用时的调试输出,然后蓝屏关闭,您会看到所有应用的初始屏幕
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Xamarin.iOS.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Mono.Security.dll [External]
Resolved pending breakpoint for 'UIKit.UIApplication.Main(System.String[], System.IntPtr, System.IntPtr)' to /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:85 [0x00000].
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Calculette.iOS.exe
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Xamarin.Forms.Platform.iOS.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Xamarin.Forms.Core.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/netstandard.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Core.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Xml.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Numerics.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Data.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Transactions.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Data.DataSetExtensions.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Drawing.Common.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.IO.Compression.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.IO.Compression.FileSystem.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.ComponentModel.Composition.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Net.Http.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Runtime.Serialization.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.ServiceModel.Internals.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Web.Services.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Xml.Linq.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Xamarin.Forms.Platform.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Calculette.dll
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/Xamarin.Forms.Xaml.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/XamForms.Controls.Calendar.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Runtime.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Resources.ResourceManager.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Collections.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.ObjectModel.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Threading.Tasks.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Globalization.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Threading.dll [External]
Loaded assembly: /Users/user179537/Library/Developer/CoreSimulator/Devices/CBBD6116-A257-42AB-B54A-9C00DF68934D/data/Containers/Bundle/Application/31B4CC71-FFB9-4A92-946F-B35391E22175/Calculette.iOS.app/System.Runtime.Extensions.dll [External]
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Calculette"
xmlns:pv="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
xmlns:views1="clr-namespace:Calculette.Views"
xmlns:converters="clr-namespace:Calculette.Converters"
x:Class="Calculette.MainPage"
BarBackgroundColor = "White"
BarTextColor="#008A00">
<TabbedPage.ToolbarItems>
<ToolbarItem Icon="logocalculette.png"></ToolbarItem>
<ToolbarItem></ToolbarItem>
<ToolbarItem></ToolbarItem>
<ToolbarItem Text="Calculette de bruit"/>
<ToolbarItem Text=""></ToolbarItem>
<ToolbarItem Text="À propos" Order="Secondary"></ToolbarItem>
<ToolbarItem Text="Références" Order="Secondary"></ToolbarItem>
<ToolbarItem Text="Mentions légales" Order="Secondary"></ToolbarItem>
<ToolbarItem Text="Aide" Order="Secondary"></ToolbarItem>
<ToolbarItem Text="Options" Order="Secondary"></ToolbarItem>
</TabbedPage.ToolbarItems>
<views1:TasksGroupPage></views1:TasksGroupPage>
<local:CalendarPage></local:CalendarPage>
</TabbedPage>
MainPage.xaml.cs
using Calculette.ViewModels;
using Calculette.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.PancakeView;
using Calculette.Views;
namespace Calculette
{
public partial class MainPage : TabbedPage
{
public MainPage()
{
InitializeComponent();
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false);
}
}
}
【问题讨论】:
-
应用程序输出窗口显示什么?
-
@Jason 您需要哪个窗口,对于输出,我可以在构建、构建顺序、调试、包管理器、Xamarin、Xamarin 诊断之间进行选择。还有一种行为,一旦应用程序安装在模拟器上,当我再次运行项目时,它永远不会立即启动应用程序,我需要点击应用程序图标才能启动
-
我添加了调试输出,它似乎卡在那里(至少 10 分钟,没有任何反应)
-
@codetime 你好,当应用关闭时,你能分享一下VS的OutPut的日志吗?另外,如果能分享一些
Fomrs的代码就更好了。 -
@JuniorJiang-MSFT 您好,抱歉,我不确定 Fomrs 的代码是什么,它在哪里?你想要哪个 Vs 输出,我从我的第二条评论中得到了选项,并且已经在帖子中出现了首次输出。谢谢!
标签: ios xamarin xamarin.forms xamarin.ios