Xamarin iOS controller Custom dependency injection inheritance problems

I have a failure with a controller that inherits from the base class. My base looks like this:

public abstract class BaseUIViewController : UIViewController { public BaseUIViewController() : base() { } public BaseUIViewController(..) : base(..) { } } 

My controller inherits from this and defines a constructor like:

 public class MyController : BaseUIViewController { public MyController(ISOmeService service, IOtherService service) { .. } override ViewDidLoad(..) { .. } } 

TinyIOC instantiates a conntroller and provides design services. For some reason, ViewDidLoad gets triggered before the constructor when I do this. When I delete the definition of the base class, it does not work without problems.

Any idea why the base class is causing problems? I can logically assume that it is related to objective-c compilation, but is there a workaround?

Thanks.

+7
inheritance c # ios xamarin
source share
1 answer

Do not touch the Controller View property in the constructor, as this will call ViewDidLoad.

+5
source share

All Articles