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


C# UITextField.ResignFirstResponder方法代码示例

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


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

示例1: textFieldShouldReturn

		private bool textFieldShouldReturn(UITextField textField)
		{
			textField.ResignFirstResponder ();
			LoadAddressURL ();

			return true;
		}
开发者ID:Luceres,项目名称:monotouch-samples,代码行数:7,代码来源:WebViewController.cs

示例2: ViewDidLoad

        public override void ViewDidLoad()
        {
            View = new UIView(){ BackgroundColor = UIColor.White};
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;


            var label = new ShapeLabel(new RectangleF(10, 10, 300, 40));
            Add(label);
            var textField = new UITextField(new RectangleF(10, 50, 300, 40));
            Add(textField);
            var shapeView = new ShapeView(new RectangleF(60, 90, 200, 200));
            Add(shapeView);

            var picker = new UIPickerView();
            var pickerViewModel = new MvxPickerViewModel(picker);
            picker.Model = pickerViewModel;
            picker.ShowSelectionIndicator = true;
            textField.InputView = picker;

            var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
            set.Bind(label).For(s => s.TheShape).To(vm => vm.Shape);
            set.Bind(textField).To(vm => vm.Shape);
            set.Bind(pickerViewModel).For(p => p.ItemsSource).To(vm => vm.List);
            set.Bind(pickerViewModel).For(p => p.SelectedItem).To(vm => vm.Shape);
            set.Bind(shapeView).For(s => s.TheShape).To(vm => vm.Shape);
            set.Apply();

            var g = new UITapGestureRecognizer(() => textField.ResignFirstResponder());
            View.AddGestureRecognizer(g);
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:34,代码来源:FirstView.cs

示例3: ViewDidLoad

        public override void ViewDidLoad()
        {
            View = new UIView(){ BackgroundColor = UIColor.White};
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            var binaryEdit = new BinaryEdit(new RectangleF(10, 70, 300, 120));
            Add(binaryEdit);
            var textField = new UITextField(new RectangleF(10, 190, 300, 40));
            Add(textField);
            var nicerBinaryEdit = new NicerBinaryEdit(new RectangleF(10, 260, 300, 120));
            Add(nicerBinaryEdit);

            var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
            // to remove the need for `For("N28")` see Setup.FillBindingNames
            set.Bind(binaryEdit).For("N28").To(vm => vm.Counter);
            set.Bind(textField).To(vm => vm.Counter);
            // to remove the need for `For(be => be.MyCount)` see Setup.FillBindingNames
            set.Bind(nicerBinaryEdit).For(be => be.MyCount).To(vm => vm.Counter);
            set.Apply();

            var tap = new UITapGestureRecognizer(() => textField.ResignFirstResponder());
            View.AddGestureRecognizer(tap);
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:27,代码来源:FirstView.cs

示例4: DismissOnDoneKey

 private static Boolean DismissOnDoneKey(UITextField textField)
 {
     // iOS: Putting the 'ss' in 'mess'
     textField.ResignFirstResponder ();
     // According to the interwebs, returning 'true' causes a line break to be entered in the current text field. Returning 'false' indicates a line break should not be entered.
     return false;
 }
开发者ID:steveperkins,项目名称:fans-of-fury,代码行数:7,代码来源:KeyboardUtil.cs

示例5: ViewDidLoad

        public override void ViewDidLoad()
        {
            View = new UIView { BackgroundColor = UIColor.White };
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
               EdgesForExtendedLayout = UIRectEdge.None;

            var textField = new UITextField(new CGRect(10, 10, 240, 40));
            Add(textField);

            var button = UIButton.FromType(UIButtonType.System);
            button.Frame = new CGRect(260, 10, 50, 40);
            button.SetTitle("Search", UIControlState.Normal);
            Add(button);

            var table = new UITableView(new CGRect(0, 50, 320, 430));
            Add(table);
            var source = new MvxStandardTableViewSource(table, "TitleText Title");
            table.Source = source;

            var set = this.CreateBindingSet<FirstView, FirstViewModel>();
            set.Bind(textField).To(vm => vm.MovieName);
            set.Bind(button).To(vm => vm.UpdateCommand);
            set.Bind(source).To(vm => vm.FoundMovies);
            set.Bind(source).For(s => s.SelectionChangedCommand).To(vm => vm.ItemSelectedCommand);
            set.Apply();

            View.AddGestureRecognizer(new UITapGestureRecognizer(() => textField.ResignFirstResponder()) {CancelsTouchesInView = false});
        }
开发者ID:ckimes89,项目名称:codecamp-mvvmcross,代码行数:31,代码来源:FirstView.cs

示例6: FinishedLaunching

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        UIApplication.SharedApplication.StatusBarHidden = true;

        image = new UIImageView (UIScreen.MainScreen.Bounds) {
            Image = UIImage.FromFile ("Background.png")
        };
        text = new UITextField (new RectangleF (44, 32, 232, 31)) {
            BorderStyle = UITextBorderStyle.RoundedRect,
            TextColor = UIColor.Black,
            BackgroundColor = UIColor.Black,
            ClearButtonMode = UITextFieldViewMode.WhileEditing,
            Placeholder = "Hello world",
        };
        text.ShouldReturn = delegate (UITextField theTextfield) {
            text.ResignFirstResponder ();

            label.Text = text.Text;
            return true;
        };

        label = new UILabel (new RectangleF (20, 120, 280, 44)){
            TextColor = UIColor.Gray,
            BackgroundColor = UIColor.Black,
            Text = text.Placeholder
        };

        var vc = new ViewController (this) { image, text, label };

        window = new UIWindow (UIScreen.MainScreen.Bounds){ vc.View };

        window.MakeKeyAndVisible ();

        return true;
    }
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:35,代码来源:hello.cs

示例7: DismissKeyboard

 public static void DismissKeyboard(this UIView view)
 {
     var tv = new UITextField (new RectangleF(-100,-100,1,1));
     view.AddSubview (tv);
     tv.BecomeFirstResponder ();
     tv.ResignFirstResponder ();
     tv.RemoveFromSuperview ();
     tv.Dispose ();
 }
开发者ID:nagyist,项目名称:iPadPos,代码行数:9,代码来源:ViewExtensions.cs

示例8: SearchShouldReturn

        protected bool SearchShouldReturn (UITextField view)
        {
            view.ResignFirstResponder ();

            if (view == txtMessage)
            {
                SendMessage();
            }

            return true;
        }
开发者ID:Morten48,项目名称:realtime-device-to-device-networking,代码行数:11,代码来源:SendMassageController.cs

示例9: ViewDidLoad

        public override void ViewDidLoad()
        {
            View = new UniversalView();

            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            // Perform any additional setup after loading the view
            var label = new UILabel(new RectangleF(10, 0, 300, 40));
            label.Text = "SubTotal";
            Add(label);

            var subTotalTextField = new UITextField(new RectangleF(10, 40, 300, 40));
            Add(subTotalTextField);

            var label2 = new UILabel(new RectangleF(10, 80, 300, 40));
            label2.Text = "Generosity?";
            Add(label2);

            var slider = new UISlider(new RectangleF(10, 120, 300, 40));
            slider.MinValue = 0;
            slider.MaxValue = 100;
            Add(slider);

            var label3 = new UILabel(new RectangleF(10, 160, 300, 40));
            label3.Text = "Tip";
            Add(label3);

            var tipLabel = new UILabel(new RectangleF(10, 200, 300, 40));
            Add(tipLabel);

            var label4 = new UILabel(new RectangleF(10, 240, 300, 40));
            label4.Text = "Total";
            Add(label4);

            var totalLabel = new UILabel(new RectangleF(10, 280, 300, 40));
            Add(totalLabel);

            var set = this.CreateBindingSet<FirstView, FirstViewModel>();
            set.Bind(subTotalTextField).To(vm => vm.SubTotal);
            set.Bind(slider).To(vm => vm.Generosity);
            set.Bind(tipLabel).To(vm => vm.Tip);
            set.Bind(totalLabel).To(vm => vm.Total);
            set.Apply();

            var gesture = new UITapGestureRecognizer(() =>
                {
                    subTotalTextField.ResignFirstResponder();
                });
            View.AddGestureRecognizer(gesture);
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:54,代码来源:FirstView.cs

示例10: HandleShouldReturn

        private bool HandleShouldReturn(UITextField textField)
        {
            if (this._command == null)
                return false;

            var text = textField.Text;
            if (!this._command.CanExecute(text))
                return false;

            textField.ResignFirstResponder();
            this._command.Execute(text);
            return true;
        }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:13,代码来源:MvxUITextFieldShouldReturnTargetBinding.cs

示例11: NameValueCell

        public NameValueCell(string name, Func<string> valueGet, Action<string> valueSet)
        {
            this.BackgroundColor = UIColor.Clear;
            this.Frame = new RectangleF (0, 0, 100, 100);

            int labelXPos = 10;
            int label2XPos = 75;
            NameLabel = new UILabel (new RectangleF (
                labelXPos, 11,  label2XPos-(labelXPos+5), 21));
            NameLabel.AutoresizingMask = UIViewAutoresizing.None;
            NameLabel.BackgroundColor = UIColor.Clear;
            NameLabel.Font = UIFont.SystemFontOfSize (14);
            NameLabel.AdjustsFontSizeToFitWidth = true;
            NameLabel.TextAlignment = UITextAlignment.Right;
            NameLabel.Text = name;
            NameLabel.TextColor = UIColor.Blue;
            this.Add (NameLabel);

            ValueLabel = new UILabel (new RectangleF (
                label2XPos, 11,  this.Frame.Width-(label2XPos+10), 21));
            ValueLabel.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            ValueLabel.BackgroundColor = UIColor.Clear;
            ValueLabel.Font = UIFont.BoldSystemFontOfSize (17);
            ValueLabel.AdjustsFontSizeToFitWidth = true;
            ValueLabel.Text = valueGet.Invoke ();
            this.Add (ValueLabel);

            ValueTextField = new UITextField (new RectangleF (
                label2XPos, 11,  this.Frame.Width-(label2XPos+10), 21));

            ValueTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            ValueTextField.BackgroundColor = UIColor.Clear;
            ValueTextField.Font = UIFont.BoldSystemFontOfSize (17);
            ValueTextField.AdjustsFontSizeToFitWidth = true;
            ValueTextField.Text = valueGet.Invoke ();
            ValueTextField.ReturnKeyType = UIReturnKeyType.Done;
            ValueTextField.ClearButtonMode = UITextFieldViewMode.Always;
            ValueTextField.ShouldReturn = delegate {
                ValueTextField.ResignFirstResponder ();
                return true;
            };

            ValueTextField.EditingDidEnd += delegate {
                _valueSet.Invoke (ValueTextField.Text);
            };

            this.Add (ValueTextField);

            _valueGet = valueGet;
            _valueSet = valueSet;
        }
开发者ID:bholmes,项目名称:XamarinEvolve2013Project,代码行数:51,代码来源:NameValueCell.cs

示例12: ShouldReturn

		public override bool ShouldReturn (UITextField textField)
		{
			if (useTagProperty) {
				var nextTag = textField.Tag + 1;
				var nextResponder = textField.Superview.ViewWithTag (nextTag);

				// If there is a responder, set focus on it.
				if (nextResponder != null)
					nextResponder.BecomeFirstResponder ();
				else
					// There is no control to focus, so hide the keyboard.
					textField.ResignFirstResponder ();
			} else {
				var currentIndex = Fields.IndexOf (textField);
				if (currentIndex == Fields.Count - 1)
					// This is the last field, so hide the keyboard.
					textField.ResignFirstResponder ();
				else
					// Set focus to the next field.
					Fields [currentIndex + 1].BecomeFirstResponder ();
			}

			return false; // Don't insert new lines :)
		}
开发者ID:davebro,项目名称:xamarin-autoscrolling,代码行数:24,代码来源:NavigationalTextFieldDelegate.cs

示例13: SearchTermsCell

        public SearchTermsCell()
            : base(Key)
        {
            TermsField = new UITextField() { BorderStyle = UITextBorderStyle.RoundedRect};
            AddSubview(TermsField);

            this.TermsField.EditingDidBegin += delegate { this.TermsField.BecomeFirstResponder(); };
            this.TermsField.EditingDidEnd += delegate
                {
                    this.TermsField.ResignFirstResponder();
                };

            this.TermsField.ShouldReturn += delegate {
                TermsField.ResignFirstResponder();
                return true;
            };
        }
开发者ID:erdennis13,项目名称:EthansList,代码行数:17,代码来源:SearchTermsCell.cs

示例14: LoginViewController

        public LoginViewController()
            : base("LoginViewController", null)
        {
            _window = new UIWindow(UIScreen.MainScreen.Bounds);

            var logoImage = new UIImageView(UIImage.FromBundle("signalr"));
            logoImage.Frame = new RectangleF(5, 50, 310, 180);

            var labeluserName = new UILabel
            {
                Text = "User name.:"
            };
            labeluserName.Frame = new RectangleF(10, 220, 100, 100);

            var input = new UITextField();
            input.Frame = new RectangleF(10, 280, 300, 30);
            input.BackgroundColor = UIColor.LightGray;
            input.ShouldReturn = delegate
            {
                input.ResignFirstResponder();
                return true;
            };

            var button = UIButton.FromType(UIButtonType.System);
            button.SetTitle("Login", UIControlState.Normal);
            button.Frame = new RectangleF(10, 320, 300, 30);
            button.TouchUpInside += (sender, e) =>
            {
                if (string.IsNullOrWhiteSpace(input.Text))
                {
                    new UIAlertView("Alert", "User name is mandatory!", null, "OK", null).Show();
                }
                else
                {

                    this.NavigationController.PushViewController(new MyViewController(input.Text), true);
                }
            };

            View.AddSubview(logoImage);
            View.AddSubview(labeluserName);
            View.AddSubview(input);
            View.AddSubview(button);
        }
开发者ID:SamukaSantos,项目名称:Xamarin-SignalR-Meetup2,代码行数:44,代码来源:LoginViewController.cs

示例15: ViewDidLoad

        /// <summary>
        /// Views the did load.
        /// </summary>
        /// <summary>
        /// Called when the View is first loaded
        /// </summary>
        public override void ViewDidLoad()
        {
            this.View = new UIView() { BackgroundColor = UIColor.White };

            base.ViewDidLoad();

            UILabel uiLabel = new UILabel(new RectangleF(10, 10, 300, 40));
            View.AddSubview(uiLabel);
            UITextField uiTextField = new UITextField(new RectangleF(10, 50, 300, 40));
            View.AddSubview(uiTextField);

            var set = this.CreateBindingSet<FirstView, FirstViewModel>();
            set.Bind(uiLabel).To(vm => vm.MyProperty);
            set.Bind(uiTextField).To(vm => vm.MyProperty);
            set.Apply();

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() => uiTextField.ResignFirstResponder());
            View.AddGestureRecognizer(tap);
        }
开发者ID:nanohex,项目名称:NinjaCoderForMvvmCross,代码行数:25,代码来源:FirstView.cs


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