How are UIApplication subclasses in Monotouch?

EDIT:

In a couple of years, everything will be easier. Now you can omit Register() , both on the application and on the applicationโ€™s delta, and instead use:

UIApplication.Main(args, typeof(CustomApp), typeof(CustomAppDelegate));


To override UIApplication.SendEvent () I want to subclass UIApplication:

 public class UIApplicationMain : UIApplication { public UIApplicationMain () : base() { } public override void SendEvent (UIEvent uievent) { base.SendEvent (uievent); } } 

In main.cs, I use this code:

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

But he fails:

 Objective-C exception thrown. Name: 

NSInternalInconsistencyException Cause: Unable to instantiate instance of UIApplication subclass. No class named UIApplicationMain loaded.

So, I'm missing some attributes that I think. But what and where?

+6
source share
1 answer

Add the [Register] attribute to your new type, for example:

  [Register ("UIApplicationMain")] public class UIApplicationMain : UIApplication { ... 

This will allow the native side to instantiate the correct type when Main is executed.

+10
source

Source: https://habr.com/ru/post/898372/


All Articles