c# - MonoTouch - Add UIActionSheet to Top Navigation Bar of my ViewController -


i've got following uiactionsheet. how add top navigation bar? preferably far right button.

var sheet = new uiactionsheet ("");             sheet.addbutton ("discard picture");             sheet.addbutton ("pick new picture");             sheet.addbutton ("cancel");             sheet.cancelbuttonindex = 2;              // dummy buttons preserve space uiimageview             (int = 0; < 4; i++) {                 sheet.addbutton("");                 sheet.subviews[i+4].alpha = 0; // , of course it's better hide them             }              var subview = new uiimageview();             subview.contentmode = uiviewcontentmode.scaleaspectfill;             subview.frame = new rectanglef(23,185,275,210);              // late steve jobs loved rounded corners. let's have respect him             subview.layer.cornerradius = 10;              subview.layer.maskstobounds = true;             subview.layer.bordercolor = uicolor.black.cgcolor;             sheet.addsubview(subview);              navigationcontroller.add(sheet); 

you can show actionsheet using showfrom methods.

in particular, showfromtoolbar shows sheet top toolbar button.

here's example shows sheet in different ways depending on whether on tablet or phone:

    void actionmenu()     {         //_actionsheet = new uiactionsheet("");         uiactionsheet actionsheet = new uiactionsheet (             "customer actions",              null,              "cancel",              "delete customer",              new string[] {"change customer"});          actionsheet.style = uiactionsheetstyle.default;         actionsheet.clicked += delegate(object sender, uibuttoneventargs args) {             switch (args.buttonindex)             {                 case 0: deletecustomer(); break;                 case 1: changecustomer(); break;             }         };          if (uidevice.currentdevice.userinterfaceidiom == uiuserinterfaceidiom.phone)             actionsheet.showfromtoolbar(navigationcontroller.toolbar);         else             actionsheet.showfrom(navigationitem.rightbarbuttonitem, true);     } 

https://github.com/slodge/mvvmcross-tutorials/blob/master/sample%20-%20customermanagement/customermanagement/customermanagement.touch/views/customerview.cs#l67


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -