See Also: UIApplicationDelegate Members
A strongly typed implementation of a class that can be used to respond to events raised by the MonoTouch.UIKit.UIApplication.
Application developers will generally override the UIApplicationDelegate.FinishedLaunching method, configure the application's main MonoTouch.UIKit.UIWindow, instantiate the top-level MonoTouch.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; } }
The MonoTouch.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 MonoTouch.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 UIApplicationDelegateThe MonoTouch.UIKit.UIApplicationDelegate of an application is typically set as one of few, or only, things done by the application's Main method. The MonoTouch.UIKit.UIApplicationDelegate exports a string using the MonoTouch.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 MonoTouch.UIKit.UIApplicationDelegate specified in the XIB or storyboard.