开发者

Monotouch - Create Custom BackButton

I'm trying to create my own BackBarButtonItem, but I'm having some problems.

My declaration:

var backButon = new UIBarButtonItem("Back",UIBarButtonItemStyle.Plain, null, null);

Exception:

Unhandled Exception: System.ArgumentNullException: Argument cannot be nu开发者_高级运维ll.
Parameter name: target

What should I put in "target" and "action" parameters?


You shouldn't use that constructor, unless you want to use the target/action pattern, I suggest:

public UIBarButtonItem (string title, UIBarButtonItemStyle style, EventHandler handler)

which you use like:

var btn = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, delegate (object sender, EventArgs e) {
    Console.WriteLine ("button clicked");
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜