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); }
Comments
Post a Comment