当前位置: 首页>>代码示例>>C#>>正文


C# UIAlertView.AddButton方法代码示例

本文整理汇总了C#中UIAlertView.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# UIAlertView.AddButton方法的具体用法?C# UIAlertView.AddButton怎么用?C# UIAlertView.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIAlertView的用法示例。


在下文中一共展示了UIAlertView.AddButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Display

		public void Display (string body, string title, GoalsAvailable goalAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
		{
			UIAlertView alert = new UIAlertView();
			alert.Title = title;
			alert.AddButton(acceptButtonTitle);
			alert.AddButton(cancelButtonTitle);
			alert.Message = body;
			alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
			alert.GetTextField(0).KeyboardType=UIKeyboardType.NumberPad;
			const int maxCharacters =7;
			alert.GetTextField(0).ShouldChangeCharacters = (textField, range, replacement) =>
			{
				var newContent = new NSString(textField.Text).Replace(range, new NSString(replacement)).ToString();
				int number;
				return newContent.Length <= maxCharacters && (replacement.Length == 0 || int.TryParse(replacement, out number));
			};
			alert.Clicked += (object s, UIButtonEventArgs ev) =>
			{
				if(action != null)
				{
					if(ev.ButtonIndex ==0)
					{
						string input = alert.GetTextField(0).Text;
						int goalValue;
						int.TryParse(input, out goalValue);
						action.Invoke(goalAvailable, goalValue);
					}
				}
			};
			alert.Show();
		}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:31,代码来源:InputGoalDialog.cs

示例2: ShowPopup

		void ShowPopup(FavoriteViewModel vm)
		{
			if (null == vm)
				return;

			var popup = new UIAlertView(View.Frame);

			popup.Title = vm.Name;

			popup.AddButton("Fjern fra favoritter");
			popup.AddButton("Vis detaljer");
			popup.AddButton("Avbryt");

			popup.CancelButtonIndex = 2;

			popup.Dismissed += (sender, e) =>
			{
				switch(e.ButtonIndex)
				{
					case 0 : 
						ViewModel.RemoveFavorite(vm.DocumentNumber, vm);
						break;

					case 1: 
						ViewModel.ShowDetailsCommand.Execute(vm);
						break;
				}
			};

			popup.Show();
		}
开发者ID:khellang,项目名称:Solvberget,代码行数:31,代码来源:MyPageFavoritesView.cs

示例3: ShowPopup

		void ShowPopup(LoanViewModel vm)
		{
			if (null == vm)
				return;

			var popup = new UIAlertView(View.Frame);

			popup.Title = vm.DocumentTitle;

			popup.AddButton("Utvid lånetid");
			popup.AddButton("Vis detaljer");
			popup.AddButton("Avbryt");

			popup.CancelButtonIndex = 2;

			popup.Dismissed += (sender, e) =>
			{
				switch(e.ButtonIndex)
				{
					case 0 : 
						ViewModel.ExpandLoan(vm.DocumentNumber);
						break;

					case 1: 
						ViewModel.ShowDetailsCommand.Execute(vm);
						break;
				}
			};

			popup.Show();
		}
开发者ID:khellang,项目名称:Solvberget,代码行数:31,代码来源:MyPageLoansView.cs

示例4: Show

        public void Show(string text, string firstOption, string secondOption, Action firstAction, Action secondAction)
        {
            Mvx.Resolve<IMvxMainThreadDispatcher>().RequestMainThreadAction(() =>
            {
                if (_alertView != null)
                {
                    _alertView.DismissWithClickedButtonIndex(0, true);
                }

                _alertView = new UIAlertView();
                _alertView.AddButton(firstOption);
                _alertView.AddButton(secondOption);
                _alertView.Message = text ?? string.Empty;

                _alertView.Clicked += (sender, arg) =>
                {
                    if (arg.ButtonIndex == 0)
                    {
                        firstAction();
                    }
                    else if (arg.ButtonIndex == 1)
                    {
                        secondAction();
                    }
                };
                _alertView.Show();
            });
        }
开发者ID:sbondini,项目名称:FriendList,代码行数:28,代码来源:TouchAlertDialog.cs

示例5: ShowPopup

		void ShowPopup(ReservationViewModel vm)
		{
			if (null == vm)
				return;

			var popup = new UIAlertView(View.Frame);

			popup.Title = vm.DocumentTitle;

			popup.AddButton("Kanseller reservasjon");
			popup.AddButton("Vis detaljer");
			popup.AddButton("Avbryt");

			popup.CancelButtonIndex = 2;

			popup.Dismissed += (sender, e) =>
			{
				switch(e.ButtonIndex)
				{
					case 0 : 
						ViewModel.RemoveReservation(vm);
						break;

					case 1: 
						ViewModel.ShowDetailsCommand.Execute(vm);
						break;
				}
			};

			popup.Show();
		}
开发者ID:khellang,项目名称:Solvberget,代码行数:31,代码来源:MyPageReservationsView.cs

示例6: PlatformShow

        private static Task<string> PlatformShow(string title, string description, string defaultText, bool usePasswordMode)
        {
            tcs = new TaskCompletionSource<string>();

            UIApplication.SharedApplication.InvokeOnMainThread(delegate
            {
                alert = new UIAlertView();
                alert.Title = title;
                alert.Message = description;
                alert.AlertViewStyle = usePasswordMode ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput;
                alert.AddButton("Cancel");
                alert.AddButton("Ok");
                UITextField alertTextField = alert.GetTextField(0);
                alertTextField.KeyboardType = UIKeyboardType.ASCIICapable;
                alertTextField.AutocorrectionType = UITextAutocorrectionType.No;
                alertTextField.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                alertTextField.Text = defaultText;
                alert.Dismissed += (sender, e) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(e.ButtonIndex == 0 ? null : alert.GetTextField(0).Text);
                };

                // UIAlertView's textfield does not show keyboard in iOS8
                // http://stackoverflow.com/questions/25563108/uialertviews-textfield-does-not-show-keyboard-in-ios8
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                    alert.Presented += (sender, args) => alertTextField.SelectAll(alert);

                alert.Show();
            });

            return tcs.Task;
        }
开发者ID:KennethYap,项目名称:MonoGame,代码行数:33,代码来源:KeyboardInput.iOS.cs

示例7: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //Se establece un borde para el textarea de las observaciones
            this.cmpDescripcion.Layer.BorderWidth = 1.0f;
            this.cmpDescripcion.Layer.BorderColor = UIColor.Gray.CGColor;
            this.cmpDescripcion.Layer.ShadowColor = UIColor.Black.CGColor;
            this.cmpDescripcion.Layer.CornerRadius = 8;

            this.btnGuardar.TouchUpInside += (sender, e) => {
                UIAlertView alert = new UIAlertView(){
                    Title = "Aviso" , Message = "¿Escorrecta la informacion?"
                };
                alert.AddButton ("SI");
                alert.AddButton ("NO");
                alert.Clicked += (s, o) => {
                    if(o.ButtonIndex==0){
                        try{
                            newDetailService = new NewDetailService();
                            String respuesta = newDetailService.SetData(TaskDetailView.tareaId, this.cmpDescripcion.Text, MainView.user);
                            if(respuesta.Equals("1")){
                                SuccesConfirmation();
                            }else if(respuesta.Equals("0")){
                                ErrorConfirmation();
                            }
                        }catch(System.Net.WebException){
                            ServerError();
                        }
                    }
                };
                alert.Show();
            };
        }
开发者ID:saedaes,项目名称:gestion2013,代码行数:34,代码来源:NewDetailTaskView.cs

示例8: DisplayButtonPress

partial         void DisplayButtonPress(NSObject sender)
        {
            DisplayLabel.Text = "Hello World";
            //			UIAlertView alert = new UIAlertView ("Title", "Display AlertView", null , "OK", "Cancel");
            //			alert.Show();

            //			UIAlertView alert = new UIAlertView ("Alert Title", "Choose from two buttons", null, "OK", new string[] {"Cancel"});
            //			alert.Clicked += (s, b) => {
            //				DisplayLabel.Text = "Button " + b.ButtonIndex.ToString () + " clicked";
            //				Console.WriteLine ("Button " + b.ButtonIndex.ToString () + " clicked");
            //			};
            //			alert.Show();

            UIAlertView alert = new UIAlertView () {
                Title = "custom buttons alert",
                Message = "this alert has custom buttons"
            };
            alert.AddButton("OK");
            alert.AddButton("custom button 1");
            alert.AddButton("Cancel");

            alert.Clicked += delegate(object a, UIButtonEventArgs b) {
                DisplayLabel.Text = "Button " + b.ButtonIndex.ToString () + " clicked";
                Console.WriteLine ("Button " + b.ButtonIndex.ToString () + " clicked"); };
            alert.Show ();
        }
开发者ID:utsavswaroop,项目名称:Xamarin,代码行数:26,代码来源:TestProject1ViewController.cs

示例9: ViewDidAppear

        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            var aleart = new UIAlertView() { Title = "Warning", Message = "Jail break iphone with btstack is required.\nShould start inquiry?" };
            aleart.AddButton("Cancel");
            aleart.AddButton("OK");
            aleart.Dismissed += new EventHandler<UIButtonEventArgs>(aleart_Dismissed);
            aleart.Show();
        }
开发者ID:reinforce-lab,项目名称:com.ReinforceLab.MonoTouch.Controls,代码行数:10,代码来源:BTInquiryViewController.cs

示例10: PromptYesNo

 public Task<bool> PromptYesNo(string title, string message)
 {
     var tcs = new TaskCompletionSource<bool>();
     var alert = new UIAlertView {Title = title, Message = message};
     alert.CancelButtonIndex = alert.AddButton("No");
     var ok = alert.AddButton("Yes");
     alert.Clicked += (sender, e) => tcs.SetResult(e.ButtonIndex == ok);
     alert.Show();
     return tcs.Task;
 }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:10,代码来源:AlertDialogService.cs

示例11: AskYesNo

		public static void AskYesNo (string title, string message)
		{
			UIAlertView alert = new UIAlertView ();
			alert.Title = title;
			alert.AddButton ("Yes");
			alert.AddButton ("No");
			alert.Message = message;
			alert.Delegate = new MyAlertViewDelegate ();
			alert.Show ();
		}
开发者ID:RobGibbens,项目名称:ArtekSoftware.Codemash,代码行数:10,代码来源:ModalHelper.cs

示例12: HandleTouchUpInside

		async void HandleTouchUpInside()
		{
			//No Network Message
			if (!CrossConnectivity.Current.IsConnected) {
				UIAlertView alert = new UIAlertView () { 
					Title = "No Network", Message = "Please Connect to Internet"
				};
				alert.AddButton ("OK");
				alert.Show ();
			} else {
				if (txtEmail.Text.Length > 0 && txtPassword.Text.Length > 0) {

//					if(await APIUtility.IsVPNConnectionStatus()){
						LoginAPIcall();
//					}
//					else{
//						UIAlertView alert = new UIAlertView () { 
//							Title = "Try Again", Message = "Check your VPN connection"
//						};
//						alert.AddButton ("OK");
//						alert.Show ();
//					}
				} else {
					UIAlertView alert = new UIAlertView () { 
						Title = "Failed..!!", Message = "Please Enter username and password"
					};
					alert.AddButton ("OK");
					alert.Show ();
				}

			}
		}
开发者ID:kumaralg2,项目名称:Jan28-TS,代码行数:32,代码来源:TSLoginVC.cs

示例13: Clicked

        public override void Clicked(UIActionSheet actionview, int buttonIndex)
        {
            if (buttonIndex == 0)
            {
                Console.Write("Satya!!!!!!");

                /*UIActivityIndicatorView spinner = new UIActivityIndicatorView(new RectangleF(0,0,200,300));
                spinner.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
                spinner.Center= new PointF(160, 140);
                spinner.HidesWhenStopped = true;
                actionview.AddSubview(spinner);
                InvokeOnMainThread(delegate() {
                    spinner.StartAnimating();
                });

                */

                var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);

                fileName = documents + "/" + fileName;

                data = NSData.FromUrl(_nsurl);
                File.WriteAllBytes(fileName,data.ToArray());

                if (File.Exists(fileName))
                {
                    UIAlertView alert = new UIAlertView();
                    alert.Title = "Download Complete";
                    alert.AddButton("Done");
                    alert.Show();
                }
                    //spinner.StopAnimating();

            }
        }
开发者ID:satendra4u,项目名称:LittelfuseCatalogs,代码行数:35,代码来源:MyActionSheetViewDelegate.cs

示例14: Login

 private void Login(object sender, EventArgs e)
 {
     if (ValidateFields ()) {
         User user = new User ();
         user.UserName = txtLogin.Text;
         user.Password = txtPassword.Text;
         if (controller.ExistUser (user)) {
             WelcomeController w = new WelcomeController ();
             this.NavigationController.PushViewController (w, true);
         } else {
             //No existe el usario con dicha contraseña en la db
             UIAlertView alert = new UIAlertView () {
                 Title = "Error", Message = "Error en el usuario o la clave"
             };
             alert.AddButton ("OK");
             alert.Show ();
         }
     } else {
         //No ha ingresado todos los campos
         UIAlertView alert = new UIAlertView () {
             Title = "Error", Message = "Por favor ingrese sus datos"
         };
         alert.AddButton ("OK");
         alert.Show ();
     }
 }
开发者ID:estemanp,项目名称:DevFestExampleiOS,代码行数:26,代码来源:LoginViewController.cs

示例15: FnTwoButtonedAlertDialog

		internal  Task<int> FnTwoButtonedAlertDialog(string strTitle,string strMessage,string strNegativeButton,string strPositiveButton)
		{
			var taskCompletionSource = new TaskCompletionSource<int> ();
			alertView =alertView ?? new UIAlertView ();
			alertView.Title = strTitle;
			alertView.Message = strMessage;
			alertView.AddButton ( strNegativeButton);
			alertView.AddButton (strPositiveButton );

			alertView.Clicked += ( (sender , e ) => taskCompletionSource.TrySetResult ( Convert.ToInt32 ( e.ButtonIndex.ToString () ) ) );
			alertView.Show ();

			Console.WriteLine ( taskCompletionSource.Task.ToString() );
			return taskCompletionSource.Task;
 
		}
开发者ID:suchithm,项目名称:SqliteDemo.iOS,代码行数:16,代码来源:AlertDialogClass.cs


注:本文中的UIAlertView.AddButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。