gpt4 book ai didi

c# - OnStart 和 App Constructor 有什么区别

转载 作者:太空狗 更新时间:2023-10-29 19:43:56 25 4
gpt4 key购买 nike

<分区>

Xamarin Forms 有以下 App 类:

public class App : Application
{
public App()
{
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
}

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
}
}

问题在构造函数中运行的代码与在 OnStart 方法中编写的代码有什么区别。不是都在您的应用程序启动时运行吗?

参见 http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/app-lifecycle/获取更多信息。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com