本文整理汇总了C#中UIActionSheet.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# UIActionSheet.AddButton方法的具体用法?C# UIActionSheet.AddButton怎么用?C# UIActionSheet.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIActionSheet
的用法示例。
在下文中一共展示了UIActionSheet.AddButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShareLink
public void ShareLink(string title, string status, string link)
{
var buttonTitle = string.Empty;
var actionSheet = new UIActionSheet("Partilhar");
actionSheet.AddButton("Facebook");
actionSheet.AddButton("Twitter");
actionSheet.Clicked += delegate(object a, UIKit.UIButtonEventArgs b)
{
if(b.ButtonIndex != -1)
{
buttonTitle = actionSheet.ButtonTitle(b.ButtonIndex);
}
};
actionSheet.Dismissed += (sender, e) =>
{
if (buttonTitle.Equals("Facebook"))
{
ShareOnService(SLServiceKind.Facebook, title, status, link);
}
else if (buttonTitle.Equals("Twitter"))
{
ShareOnService(SLServiceKind.Twitter, title, status, link);
}
};
actionSheet.ShowInView(UIApplication.SharedApplication.KeyWindow.RootViewController.View);
}
示例2: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
_picker = new UIImagePickerController ();
_pickerDel = new PickerDelegate (this);
_picker.Delegate = _pickerDel;
_actionSheet = new UIActionSheet ();
_actionSheet.AddButton ("Library");
_actionSheet.AddButton ("Camera");
_actionSheet.AddButton ("Cancel");
_actionSheet.CancelButtonIndex = 2;
_actionSheet.Delegate = new ActionSheetDelegate (this);
showPicker.TouchUpInside += delegate { _actionSheet.ShowInView (this.View); };
playMovie.Hidden = true;
playMovie.TouchUpInside += delegate {
if (_mp != null) {
View.AddSubview (_mp.View);
_mp.SetFullscreen (true, true);
_mp.Play ();
}
};
}
示例3: PickRegisterOption
private void PickRegisterOption()
{
try {
UIActionSheet actionSheet;
actionSheet = new UIActionSheet();
actionSheet.AddButton("Phone");
actionSheet.AddButton("Email");
actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
if (b.ButtonIndex == (0)) {
EmailRegisterView.Hidden = true;
PhoneRegisterView.Hidden = false;
SetEditing(false, true);
this.registerMode = this.appDelegate.MODE_REGISTER_PHONE;
} else {
EmailRegisterView.Hidden = false;
PhoneRegisterView.Hidden = true;
this.registerMode = this.appDelegate.MODE_REGISTER_EMAIL;
SetEditing(false, true);
}
};
actionSheet.ShowInView(View);
} catch (Exception ex) {
Console.Write(ex.Message);
}
}
示例4: HandleRightButtonClicked
private void HandleRightButtonClicked(object sender, EventArgs e)
{
var sheet = new UIActionSheet("Actions");
sheet.AddButton("Add");
sheet.AddButton("Kill");
sheet.Clicked += HandleActionSheetButtonClicked;
sheet.ShowFrom(_rightButton, true);
}
示例5: OnAddAnimalsClick
partial void OnAddAnimalsClick(MonoTouch.Foundation.NSObject sender)
{
var sheet = new UIActionSheet("Add Animals");
sheet.AddButton("Add Dog");
sheet.AddButton("Add Kitten");
sheet.Clicked += HandleAddAnimalClicked;
sheet.ShowInView(this.View);
}
示例6: HandleBtnActionSheetWithOtherButtonsTouchUpInside
protected void HandleBtnActionSheetWithOtherButtonsTouchUpInside (object sender, EventArgs e)
{
actionSheet = new UIActionSheet ("action sheet with other buttons");
actionSheet.AddButton ("delete");
actionSheet.AddButton ("a different option!");
actionSheet.AddButton ("another option");
actionSheet.DestructiveButtonIndex = 0;
actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) { Console.WriteLine ("Button " + b.ButtonIndex.ToString () + " clicked"); };
actionSheet.ShowInView (View);
}
示例7: HandleBtnActionSheetWithOtherButtonsTouchUpInside
void HandleBtnActionSheetWithOtherButtonsTouchUpInside (object sender, EventArgs e)
{
actionSheet = new UIActionSheet ("action sheet with other buttons");
actionSheet.AddButton ("delete");
actionSheet.AddButton ("a different option!");
actionSheet.AddButton ("another option");
actionSheet.DestructiveButtonIndex = 0;
actionSheet.Clicked += (object a, UIButtonEventArgs b) => {
Console.WriteLine (string.Format("Button {0} clicked", b.ButtonIndex));
};
actionSheet.ShowInView (View);
}
示例8: HandleBtnActionSheetWithOtherButtonsTouchUpInside
void HandleBtnActionSheetWithOtherButtonsTouchUpInside (object sender, EventArgs e)
{
actionSheet = new UIActionSheet ("action sheet with other buttons");
actionSheet.AddButton ("delete");
actionSheet.AddButton ("cancel");
actionSheet.AddButton ("a different option!");
actionSheet.AddButton ("another option");
actionSheet.DestructiveButtonIndex = 0;
actionSheet.CancelButtonIndex = 1;
actionSheet.Clicked += OnClicked;
actionSheet.ShowInView (View);
}
示例9: SetupActionSheet
private void SetupActionSheet()
{
_actionSheet = new UIActionSheet("Comment Actions");
_actionSheet.AddButton("Take Photo");
_actionSheet.AddButton("Attach Image");
_actionSheet.AddButton("Record Audio");
_actionSheet.AddButton("Cancel");
_actionSheet.CancelButtonIndex = 3;
_actionSheet.Clicked += _actionSheet_Clicked;
}
示例10: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Show an action sheet with Schedule, Calendar & more when navbar button is clicked.
this.NavigationItem.RightBarButtonItem.Clicked += (sender, e) => {
UIActionSheet a = new UIActionSheet("Options");
nint s = a.AddButton("Schedule"), co = a.AddButton("Call-Out"),c = a.AddButton("Calendar"), b = a.AddButton("Change Filters");
a.AddButton("Cancel");
a.Clicked += (sr, ev) => {
if (ev.ButtonIndex == s) {
if (UIDevice.CurrentDevice.CheckSystemVersion(9,0)) {
var sfViewCtrl = new SFSafariViewController (new NSUrl(Api.SCHEDULE_URL));
PresentViewControllerAsync (sfViewCtrl, true);
} else {
UIApplication.SharedApplication.OpenUrl(new NSUrl(Api.SCHEDULE_URL));
}
} else if (ev.ButtonIndex == c) {
this.PerformSegue("Calendar", this);
} else if (ev.ButtonIndex == co) {
this.NavigationController.PushViewController(new CalloutViewCtrl(), true);
} else if (ev.ButtonIndex == b) {
UIActionSheet aSheet = new UIActionSheet("Options");
nint all = aSheet.AddButton("Show All"), hide = aSheet.AddButton("Hide Biz Calc"), only = aSheet.AddButton("Biz Calc Only");
aSheet.Clicked += (sdr, evt) => {
if (evt.ButtonIndex == all) {
KeyStore.HideBizCalc = KeyStore.BizCalcOnly = false;
} else if (evt.ButtonIndex == hide) {
KeyStore.HideBizCalc = true;
KeyStore.BizCalcOnly = false;
} else if (evt.ButtonIndex == only) {
KeyStore.HideBizCalc = false;
KeyStore.BizCalcOnly = true;
}
this.UpdateData();
};
aSheet.ShowInView(this.View);
}
};
a.ShowInView(this.View);
};
// Refresh Data if the RefreshControl is manually pulled down.
this.RefreshControl.ValueChanged += (sender, e) => {
this.UpdateData();
};
this.UpdateData ();
}
示例11: SelectOption
public void SelectOption (string title, string[] options, Action<int> confirmationAction)
{
Utils.EnsureInvokedOnMainThread (() => {
var sheet = new UIActionSheet(title ?? string.Empty);
foreach(var item in options)
sheet.AddButton(item);
sheet.AddButton("Cancel");
sheet.CancelButtonIndex = sheet.ButtonCount - 1;
sheet.Dismissed += (sender, e) => confirmationAction ((int)e.ButtonIndex);
sheet.ShowInView(UIApplication.SharedApplication.KeyWindow);
});
}
示例12: Options_Click
private void Options_Click(object sender, EventArgs e)
{
UIActionSheet optionsSheet = new UIActionSheet();
optionsSheet.AddButton("Desk settings");
optionsSheet.AddButton("Add card here");
optionsSheet.AddButton("Edit current card");
optionsSheet.AddButton("Delete current card");
optionsSheet.AddButton("Cancel");
optionsSheet.CancelButtonIndex = 4;
optionsSheet.DestructiveButtonIndex = 3;
optionsSheet.Clicked += this.OptionsSheet_Clicked;
optionsSheet.ShowInView(this.View);
}
示例13: FinishedLaunching
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
JsBridge.EnableJsBridge();
window = new UIWindow (UIScreen.MainScreen.Bounds);
// the MT_JsBridgeViewController just contains a single UIWebView exposed as "WebView".
viewController = new MT_JsBridgeViewController ();
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
//// load our local index.html file
// get path to file.
string path = NSBundle.MainBundle.PathForResource( "www/index", "html" );
// create an address and escape whitespace
string address = string.Format("file:{0}", path).Replace( " ", "%20" );
// be sure to enable JS Bridge before trying to fire events.
viewController.WebView.LoadRequest(new NSUrlRequest(new NSUrl(address)));
// listen for the doNativeStuff event triggered by the browser.
viewController.WebView.AddEventListener( "doNativeStuff", delegate(FireEventData arg) {
Console.WriteLine("doNativeStuff Callback:");
Console.WriteLine(arg.Data["msg"]);
// trigger doBrowserStuff event in browser.
viewController.WebView.FireEvent( "doBrowserStuff", new {
Message = "The Native code says hi back. ;)",
Extra = "more properties",
Success = true
});
});
// listen for the nativeSheet event triggered by the browser.
viewController.WebView.AddEventListener( "nativeSheet", delegate(FireEventData arg) {
// show a native action sheet
BeginInvokeOnMainThread (delegate {
var sheet = new UIActionSheet ( "Your Action Sheet" );
sheet.AddButton ( arg.Data["msg"].ToString() );
sheet.AddButton ( "Cancel" );
sheet.CancelButtonIndex = 1;
sheet.ShowInView ( viewController.View );
});
});
return true;
}
示例14: SetupActionSheet
private void SetupActionSheet()
{
_actionSheet = new UIActionSheet("Incident Actions");
_actionSheet.AddButton("Close Incident");
//_actionSheet.AddButton("Take Photo");
//_actionSheet.AddButton("Attach Image");
//_actionSheet.AddButton("Record Audio");
_actionSheet.AddButton("Add Comment");
_actionSheet.AddButton("Cancel");
_actionSheet.DestructiveButtonIndex = 0;
_actionSheet.CancelButtonIndex = 2;
_actionSheet.Clicked += _actionSheet_Clicked;
}
示例15: ShowOptionsMenu
public static void ShowOptionsMenu(this UIViewController vc, IParentMenu parentMenu)
{
if (parentMenu == null)
{
return;
}
var actionSheet = new UIActionSheet();
#warning TODO - make this OO - let the _parentMenu render itself...
var actions = new List<ICommand>();
foreach (var child in parentMenu.Children)
{
var childCast = child as CaptionAndIconMenu;
#warning More to do here - e.g. check for null!
actionSheet.AddButton(childCast.Caption);
actions.Add(childCast.Command);
}
actionSheet.Clicked += (object sender, UIButtonEventArgs e) =>
{
if (e.ButtonIndex >= 0)
{
actions[e.ButtonIndex].Execute(null);
}
};
#warning More to do here - e.g. check for null!
//if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
// actionSheet.ShowFromToolbar(NavigationController.Toolbar);
//else
actionSheet.ShowFrom(vc.NavigationItem.RightBarButtonItem, true);
}