UIKit.UIApplicationDelegate Class
A class used to receive events raised by a UIKit.UIApplication.

See Also: UIApplicationDelegate Members

Syntax

[Foundation.Model]
[Foundation.Protocol]
[Foundation.Register("UIApplicationDelegate", false)]
public class UIApplicationDelegate : Foundation.NSObject, IUIApplicationDelegate, IDisposable

Remarks

A strongly typed implementation of a class that can be used to respond to events raised by the UIKit.UIApplication.

Application developers will generally override the UIApplicationDelegate.FinishedLaunching method, configure the application's main UIKit.UIWindow, instantiate the top-level UIKit.UIViewController, and assign it to the UIWindow.RootViewController.

This is what a minimal UIApplicationDelegate class looks like:

C# Example

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
	UIWindow window;

	public override bool FinishedLaunching (UIApplication app, NSDictionary options)
	{
		window = new UIWindow (UIScreen.MainScreen.Bounds);
		window.RootViewController = new UIViewController ();
		window.MakeKeyAndVisible ();
		
		return true;
	}
}
Operation
UIApplicationDelegate and the Application Lifecycle

The UIKit.UIApplicationDelegate provides overridable methods for the entire application lifecycle:

Applications have four major modes:

As mentioned previously, the most commonly overridden method is UIApplicationDelegate.FinishedLaunching, which is the standard place to initialize the application's UIKit.UIWindow and that window's UIWindow.RootViewController.

iOS applications should be designed to be long-lived, with many transitions between foreground processing and being suspended or backgrounded.

Assigning a UIApplicationDelegate

The UIKit.UIApplicationDelegate of an application is typically set as one of few, or only, things done by the application's Main method. The UIKit.UIApplicationDelegate exports a string using the Foundation.RegisterAttribute and this string is used as the delegateClassName argument to the UIApplication.Main(string[], string, string) method, as shown in the following example:

C# Example

public class Application 
{
		static void Main(string[] args)
		{
			UIApplication.Main(args, null, "AppDelegate");
		}
	}

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
//...etc
}

Application's that are launched from a XIB or storyboard use the UIKit.UIApplicationDelegate specified in the XIB or storyboard.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0