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


C# UIAlertView.GetTextField方法代码示例

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


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

示例1: 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

示例2: 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

示例3: addNewItem

 public void addNewItem(object sender, EventArgs e)
 {
     UIAlertView alert = new UIAlertView(
         NSBundle.MainBundle.LocalizedString("Create an Asset Type", "Create Asset Type"),
         NSBundle.MainBundle.LocalizedString("Please enter a new asset type", "Please Enter"),
         null,
         NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"),
         new string[]{NSBundle.MainBundle.LocalizedString("Done", "Done")});
     alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
     UITextField alerttextField = alert.GetTextField(0);
     alerttextField.KeyboardType = UIKeyboardType.Default;
     alerttextField.Placeholder = NSBundle.MainBundle.LocalizedString("Enter a new asset type", "Enter New");
     alert.Show(); // Use for silver challenge
     alert.Clicked += (object avSender, UIButtonEventArgs ave) => {
         if (ave.ButtonIndex == 1) {
             Console.WriteLine("Entered: {0}", alert.GetTextField(0).Text);
             BNRItemStore.addAssetType(alert.GetTextField(0).Text);
             TableView.ReloadData();
             NSIndexPath ip = NSIndexPath.FromRowSection(BNRItemStore.allAssetTypes.Count-1, 0);
             this.RowSelected(TableView, ip);
         } else {
             this.NavigationController.PopViewController(true);
         }
     };
 }
开发者ID:yingfangdu,项目名称:BNR,代码行数:25,代码来源:AssetTypePicker.cs

示例4: LoadView

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

            _MapView = new MapView() {
                MyLocationEnabled = true,
            };
            _Markers.ForEach(mmi => mmi.Map = _MapView);
            _MapView.Settings.RotateGestures = false;
            _MapView.Tapped += (object tapSender, GMSCoordEventArgs coordEventArgs) => {
                UIAlertView nameInputAlertView = new UIAlertView("Add New Marker", "", null, "Cancel", new[] { "Add" }) {
                    AlertViewStyle = UIAlertViewStyle.PlainTextInput,
                };
                UITextField nameTextField = nameInputAlertView.GetTextField(0);
                nameTextField.Placeholder = "Marker name";
                nameTextField.BecomeFirstResponder();
                nameInputAlertView.Dismissed += (sender, e) => {
                    if (e.ButtonIndex != nameInputAlertView.CancelButtonIndex) {
                        MarkerInfo newMarkerInfo = new MarkerInfo() {
                            Latitude = coordEventArgs.Coordinate.Latitude,
                            Longitude = coordEventArgs.Coordinate.Longitude,
                            Name = nameTextField.Text,
                        };
                        NewMarkerCreated(this, new MarkerAddedEventArgs(newMarkerInfo));
                    }
                };
                nameInputAlertView.Show();
            };
            View = _MapView;
        }
开发者ID:patridge,项目名称:demos-xamarin.ios-tour,代码行数:29,代码来源:MapViewController.cs

示例5: SignIn

		async Task<bool> SignIn()
		{
			var tcs = new TaskCompletionSource<bool> ();
			var alert = new UIAlertView ("Please sign in", "", null, "Cancel", "Ok");
			alert.AlertViewStyle = UIAlertViewStyle.SecureTextInput;
			var tb = alert.GetTextField(0);
			tb.ShouldReturn = (t)=>{

				alert.DismissWithClickedButtonIndex(1,true);
				signIn(tcs,tb.Text);
				return true;
			};

			alert.Clicked += async (object sender, UIButtonEventArgs e) => {
				if(e.ButtonIndex == 0)
				{
					tcs.TrySetResult(false);
					alert.Dispose();
					return;
				}

				var id = tb.Text;
				signIn(tcs,id);
			
			
			};
			alert.Show ();
			return await tcs.Task;
		}
开发者ID:nagyist,项目名称:iPadPos,代码行数:29,代码来源:PaymentViewController.cs

示例6: Login

        public override void Login(LoginConfig config) {
            UITextField txtUser = null;
            UITextField txtPass = null;

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) {
                var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
                dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true))));
                dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false))));

                dlg.AddTextField(x => {
                    txtUser = x;
                    x.Placeholder = config.LoginPlaceholder;
                    x.Text = config.LoginValue ?? String.Empty;
                });
                dlg.AddTextField(x => {
                    txtPass = x;
                    x.Placeholder = config.PasswordPlaceholder;
                    x.SecureTextEntry = true;
                });
                this.Present(dlg);
            }
            else {
                var dlg = new UIAlertView {
                    AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput,
                    Title = config.Title,
					Message = config.Message
                };
                txtUser = dlg.GetTextField(0);
                txtPass = dlg.GetTextField(1);

                txtUser.Placeholder = config.LoginPlaceholder;
                txtUser.Text = config.LoginValue ?? String.Empty;
                txtPass.Placeholder = config.PasswordPlaceholder;

                dlg.AddButton(config.OkText);
                dlg.AddButton(config.CancelText);
                dlg.CancelButtonIndex = 1;

                dlg.Clicked += (s, e) => {
                    var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
                    config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok));
                };
                this.Present(dlg);
            }
        }
开发者ID:rmawani,项目名称:userdialogs,代码行数:45,代码来源:UserDialogsImpl.cs

示例7: Dismissed

 public override void Dismissed(UIAlertView alertView, int buttonIndex)
 {
     if (buttonIndex == alertView.CancelButtonIndex)
         cancelAction();
     else if (alertView.AlertViewStyle == UIAlertViewStyle.SecureTextInput)
         okActionOfString(alertView.GetTextField(0).Text);
     else
         okAction();
 }
开发者ID:samilamti,项目名称:axcrypt-net,代码行数:9,代码来源:UIAlertViewOkCancelDelegate.cs

示例8: Login

        public override void Login(LoginConfig config) {
            this.Dispatch(() => {
                var dlg = new UIAlertView { AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput };
                var txtUser = dlg.GetTextField(0);
                var txtPass = dlg.GetTextField(1);

                txtUser.Placeholder = config.LoginPlaceholder;
                txtUser.Text = config.LoginValue ?? String.Empty;
                txtPass.Placeholder = config.PasswordPlaceholder;
                txtPass.SecureTextEntry = true;

                dlg.Clicked += (s, e) => {
                    var ok = (dlg.CancelButtonIndex != e.ButtonIndex);
                    config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok));
                };
                dlg.Show();
            });
        }
开发者ID:Mvvmcross-Cn,项目名称:acrmvvmcross,代码行数:18,代码来源:TouchUserDialogService.cs

示例9: Display

		public void Display (string body, string title, BarriersAvailable barrierAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<BarriersAvailable, string> action = null)
		{
			UIAlertView alert = new UIAlertView();
			alert.Title = title;
			alert.AddButton(acceptButtonTitle);
			alert.AddButton(cancelButtonTitle);
			alert.Message = body;
			alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
			var textField = alert.GetTextField (0);
			CGRect frameRect = textField.Frame;
			CGSize size = new CGSize (150, 60);
			frameRect.Size = size;
			textField.Frame = frameRect;


			alert.Clicked += (object s, UIButtonEventArgs ev) =>
			{
				if(action != null)
				{
					if(ev.ButtonIndex ==0)
					{
						string input = alert.GetTextField(0).Text;
						action.Invoke(barrierAvailable, input);
					}
				}
			};
			alert.Show();


//			UIAlertController alert = UIAlertController.Create (title, body, UIAlertControllerStyle.Alert);
//
//			alert.AddAction (UIAlertAction.Create (acceptButtonTitle, UIAlertActionStyle.Default, action2 => {
//				//SendComment(alert.TextFields[0].Text);
//				string input = alert.TextFields[0].Text;
//				action.Invoke(barrierAvailable, input);
//			}));
//
//			alert.AddAction (UIAlertAction.Create (cancelButtonTitle, UIAlertActionStyle.Cancel, null));
//			alert.AddTextField ((field) => {
//				field.Placeholder = title;
//			});
//
//			alert.
		}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:44,代码来源:InputBarrierDialogue.cs

示例10: PromptTextBox

 public Task<string> PromptTextBox(string title, string message, string defaultValue, string okTitle)
 {
     var tcs = new TaskCompletionSource<string>();
     var alert = new UIAlertView();
     alert.Title = title;
     alert.Message = message;
     alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
     var cancelButton = alert.AddButton("Cancel");
     var okButton = alert.AddButton(okTitle);
     alert.CancelButtonIndex = cancelButton;
     alert.GetTextField(0).Text = defaultValue;
     alert.Clicked += (s, e) =>
     {
         if (e.ButtonIndex == okButton)
             tcs.SetResult(alert.GetTextField(0).Text);
         else
             tcs.SetCanceled();
     };
     alert.Show();
     return tcs.Task;
 }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:21,代码来源:AlertDialogService.cs

示例11: AskForString

 public void AskForString(string message, string title, System.Action<string> returnString)
 {
     Helpers.EnsureInvokedOnMainThread (() => {
     var alertView = new UIAlertView (title ?? string.Empty, message, null, "OK", "Cancel");
     alertView.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
     alertView.Clicked += (sender, e) => {
         var text = alertView.GetTextField(0).Text.Trim();
         if(e.ButtonIndex == 0 && !string.IsNullOrWhiteSpace(text))
             returnString (text);
     };
     alertView.Show ();
     });
 }
开发者ID:rferolino,项目名称:MeetupManager,代码行数:13,代码来源:MessageDialog.cs

示例12: Save

		private void Save() 
		{
			/*
			_messageDb.SaveMessage(textViewMessage.Text);
			*/
			var alert = new UIAlertView("Enter Password", "Password", null, "OK", null) {
				AlertViewStyle = UIAlertViewStyle.SecureTextInput
			};
			alert.Clicked += (s, a) =>  {
				_messageDb.Password = alert.GetTextField(0).Text;
				_messageDb.SaveMessage(textViewMessage.Text);
			};
			alert.Show();

		}
开发者ID:nagyist,项目名称:mini-hacks,代码行数:15,代码来源:MainViewController.cs

示例13: EnterTextMessage

    public void EnterTextMessage(string title, string message, Action<string> completed)
    {
      var alert = new UIAlertView(title, message, null, "Enter", "Cancel")
      {
        AlertViewStyle = UIAlertViewStyle.PlainTextInput
      };
      alert.Dismissed += (sender2, args) =>
      {
        if (args.ButtonIndex != 0)
          return;

        completed(alert.GetTextField(0).Text.Trim());
        
      };
      alert.Show(); 
    }
开发者ID:IanLeatherbury,项目名称:evolve-quest,代码行数:16,代码来源:Messages.cs

示例14: Input

 public void Input(string message, Action<bool, string> answer, string placeholder = null, string title = null, string okButton = "OK", string cancelButton = "Cancel")
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() =>
     {
         var input = new UIAlertView(title ?? string.Empty, message, null, cancelButton, okButton);
         input.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
         var textField = input.GetTextField(0);
         textField.Placeholder = placeholder;
         if (answer != null)
         {
             input.Clicked +=
                 (sender, args) =>
                     answer(input.CancelButtonIndex != args.ButtonIndex, textField.Text);
         }
         input.Show();
     });
 }
开发者ID:kobynet,项目名称:MvvmCross-UserInteraction,代码行数:17,代码来源:UserInteraction.cs

示例15: HandleCreateSheetClicked

		void HandleCreateSheetClicked (object sender, UIButtonEventArgs e)
		{
			var actionSheet = (UIActionSheet)sender;
			if (e.ButtonIndex != actionSheet.CancelButtonIndex) {
				creatingFolder = e.ButtonIndex > 0;
				string title = creatingFolder ? "Create folder" : "Create a file";
				var alert = new UIAlertView (title, "", null, "Cancel", new string[] {"Create"});
				alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
				alert.Clicked += (s, a) => {
					if (a.ButtonIndex != alert.CancelButtonIndex) {
						string input = alert.GetTextField (0).Text;
							CreateAt (input);
					}
					DispatchQueue.DefaultGlobalQueue.DispatchAsync (() => LoadFiles ());
				};
				alert.Show ();
			}
		}
开发者ID:davidlook,项目名称:dropbox-sync-component,代码行数:18,代码来源:DVCFiles.cs


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