I have a xib file - LoaderView.xib and associated class LoaderView.cs which contains a view for showing loading text. When I try to load it in the main ViewController as -
public override void ViewDidAppear()
{
base.ViewDidAppear();
NSBundle.MainBundle.LoadNibNamed("LoaderView", this, out NSArray arr);
var view = Runtime.GetNSObject<LoaderView>(arr.ValueAt(0));
view.Frame = View.Frame;
View.AddSubview(view);
}
I am getting the System.InvalidCastException in this line -
var view = Runtime.GetNSObject<LoaderView>(arr.ValueAt(0));
And the strange part is I do not get the exception every time. When it works, I am seeing the loading text overlapped with default view - associated with the ViewController.
Can someone point out what is the best way to show Loading, Error and Empty states. Should I have separate ViewControllers for them? Or Can I have separate xib files which I can load/unload from the main View Controller? How to load a view from a xib file?