Monotouch: Create IBOutlet and Actions Programmatically

I need to create IBOutlet and IBActions without using Interface Builder. How can i do

Thanks in advance. Regards.

+3
source share
2 answers

I'm not sure how you plan on connecting IBOutlet or IBAction without a pen tip backing, but you can create the necessary bits manually.

IBActions are just an interface that can decorate a selector contract with an implementation. You can manually create a method associated with the selector with the following code example:

[Export ("someMethod:")]
public void SomeMethod (int arg) {
}

IBOutlets - , (ivars). Ivars monotouch , - . - :

[Connect("varname")]
private NSObject varname {
    get {
        return ((NSObject) (this.GetNativeField("varname")));
    }
    set {
        this.SetNativeField("varname", value);
    }
}

, MT :

private NSObject __mt_varname;
[Connect("varname")]
private NSObject varname {
    get {
        this.__mt_varname = ((NSObject) (this.GetNativeField("varname")));
            return this.__mt_varname;
    }
    set {
            this.__mt_varname = value;
        this.SetNativeField("varname", value);
    }
}

- , , , .

+2

, , XIB , 2

Miguel MonoTouch.Dialog

These 2 articles will help you anyway.

Alex

+1
source

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


All Articles