csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
using Foundation;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
|
|
using UIKit;
|
|
|
|
namespace Avalonia.iOS
|
|
{
|
|
public class AvaloniaAppDelegate<TApp> : UIResponder, IUIApplicationDelegate
|
|
where TApp : Application, new()
|
|
{
|
|
class SingleViewLifetime : ISingleViewApplicationLifetime
|
|
{
|
|
public AvaloniaView View;
|
|
|
|
public Control MainView
|
|
{
|
|
get => View.Content;
|
|
set => View.Content = value;
|
|
}
|
|
}
|
|
|
|
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseiOS();
|
|
|
|
[Export("window")]
|
|
public UIWindow Window { get; set; }
|
|
|
|
[Export("application:didFinishLaunchingWithOptions:")]
|
|
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
|
|
{
|
|
var builder = AppBuilder.Configure<TApp>();
|
|
CustomizeAppBuilder(builder);
|
|
|
|
var lifetime = new SingleViewLifetime();
|
|
|
|
builder.AfterSetup(_ =>
|
|
{
|
|
Window = new UIWindow();
|
|
var view = new AvaloniaView();
|
|
lifetime.View = view;
|
|
Window.RootViewController = new UIViewController
|
|
{
|
|
View = view
|
|
};
|
|
});
|
|
|
|
builder.SetupWithLifetime(lifetime);
|
|
|
|
Window.Hidden = false;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|