开发者

Monotouch: load XIB asynchronously

开发者 https://www.devze.com 2023-02-15 03:38 出处:网络
I would like to know what is the right manner for calling external XIB. The method MonoTouch.Foundation.NSBundle.MainBundle.LoadNib loads a XIB in a synchronous way but, in this manner, I can\'t over

I would like to know what is the right manner for calling external XIB.

The method MonoTouch.Foundation.NSBundle.MainBundle.LoadNib loads a XIB in a synchronous way but, in this manner, I can't override ViewDidLoad method.

In particular, my goal is to crete a custom UIViewController and load a XIB created in IB (this element is an item that is attached to a Superview). Then I would attach a tap action on the custom UIView. Without overriding ViewDidLoad method I'm not able to do it.

How can I find a good tutorial to understand all the different constructor which I can utilize into a UIViewController?

For example, Could you explain these ctors?

public MyCustomView (IntPtr handle) : base(handle)
{
    Initialize ();
}

[Export("initWithCoder:")]
public MyCustomView (NSCoder coder) : base(coder)
{
    Initialize ();
}

public MyCustomView () : base("MyCustomView", null)
{
    //---- this next lin开发者_StackOverflowe forces the loading of the xib file to be synchronous
    MonoTouch.Foundation.NSBundle.MainBundle.LoadNib ("MyCustomView", this, null);
    Initialize ();
}

Thank you very much. Best Regards.


The concept you try to do seems to me like changing the behavior of the default event and action flow in CocoaTouch.

The thing is, that ViewDidLoad is exactly the place where you should do the initialization, not in the constructor itself, leave the NIB loading on the framework and just handle the ViewDidLoad as it is intended.

It really helps to read the apple's development documentation, this helped me a lot at the start: https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html

0

精彩评论

暂无评论...
验证码 换一张
取 消