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");
});
精彩评论