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


C# UITextView.ResignFirstResponder方法代码示例

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


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

示例1: ViewDidLoad

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

		Title = "Text View";
		textView = new UITextView (View.Frame){
			TextColor = UIColor.Black,
			Font = UIFont.FromName ("Arial", 18f),
			BackgroundColor = UIColor.White,
			Text = "This code brought to you by ECMA 334, ECMA 335 and the Mono Team at Novell\n\n\nEmbrace the CIL!",
			ReturnKeyType = UIReturnKeyType.Default,
			KeyboardType = UIKeyboardType.Default,
			ScrollEnabled = true,
			AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
		};

		// Provide our own save button to dismiss the keyboard
		textView.Started += delegate {
			var saveItem = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
				textView.ResignFirstResponder ();
				NavigationItem.RightBarButtonItem = null;
				});
			NavigationItem.RightBarButtonItem = saveItem;
		};

		View.AddSubview (textView);
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:27,代码来源:textview.cs

示例2: UiSetKeyboardEditorWithCloseButton

        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle = UIBarStyle.Black,
                Translucent = true,
            };
            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset = UIEdgeInsets.Zero,
                KeyboardType = keyboardType,
                Text = txt.Text,
                UserInteractionEnabled = true
            };
            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                 (s, e) =>
                {
                    text.ResignFirstResponder();
                    txt.ResignFirstResponder();
                });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
开发者ID:nodoid,项目名称:mvvmlight1,代码行数:32,代码来源:UIUtils.cs

示例3: ShouldChangeText

		public override bool ShouldChangeText (UITextView textView, NSRange range, string text)
		{
			if (!text.Contains ("\n"))
				return true;

			textView.ResignFirstResponder ();
			return false;
		}
开发者ID:Clancey,项目名称:aws-sdk-net,代码行数:8,代码来源:SNSSampleViewController.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{	
			base.ViewDidLoad ();
			
			#region UI Controls (you could do this in XIB if you want)
			saveButton = UIButton.FromType(UIButtonType.RoundedRect);
			saveButton.Frame = new RectangleF(10,10,145,50);
			saveButton.SetTitle("Save", UIControlState.Normal);
			saveButton.SetTitle("waiting...", UIControlState.Disabled);
			saveButton.Enabled = false;
			
			doneSwitch = new UISwitch();
			doneSwitch.Frame = new RectangleF(180, 25, 145, 50);
			doneSwitch.Enabled = false;
			doneLabel = new UILabel();
			doneLabel.Frame = new RectangleF(200, 10, 145, 15);
			doneLabel.Text = "Done?";

			titleText = new UITextView(new RectangleF(10, 70, 300, 40));
			titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
			titleText.Editable = true;
			titleText.BackgroundColor = UIColor.FromRGB(240,240,240);

			descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
			descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
			descriptionText.Editable = true;
			descriptionText.ScrollEnabled = true;
			descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

			// Add the controls to the view
			this.Add(saveButton);
			this.Add(doneLabel);
			this.Add(doneSwitch);
			this.Add(descriptionText);
			this.Add(titleText);
			#endregion

			saveButton.TouchUpInside += (sender, e) => {

				doc.TheTask.Title = titleText.Text;
				doc.TheTask.Description = descriptionText.Text;
				doc.TheTask.IsDone = doneSwitch.On;

				doc.UpdateChangeCount (UIDocumentChangeKind.Done);	// tell UIDocument it needs saving
				descriptionText.ResignFirstResponder ();			// hide keyboard
				titleText.ResignFirstResponder ();
			};
			
			LoadData ();

			NSNotificationCenter.DefaultCenter.AddObserver (this
				, new Selector("dataReloaded:")
				, new NSString("taskModified"),
				null);

		}
开发者ID:GSerjo,项目名称:Seminars,代码行数:56,代码来源:TaskScreen.cs

示例5: EditingEnded

        public override void EditingEnded(UITextView textView)
        {
            if (textView.Text == "") {
                textView.Text = "Content";
                textView.TextColor = UIColor.LightGray;
                textView.Font = FontConstants.SourceSansProBold (13);
            }

            textView.ResignFirstResponder ();
        }
开发者ID:pierceboggan,项目名称:Verses,代码行数:10,代码来源:ContentTextDelegate.cs

示例6: EditingEnded

		public override void EditingEnded (UITextView textView)
		{
			if (textView.Text == "") 
			{
				textView.Text = "Add Comment";
				textView.TextColor = UIColor.DarkGray;
			}

			textView.ResignFirstResponder ();
		}
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:10,代码来源:CommentTextBoxRenderer.cs

示例7: SetupToolbarOnKeyboard

        public void SetupToolbarOnKeyboard(UITextView txt)
        {
            UIToolbar toolbar = new UIToolbar ();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem ("Close", UIBarButtonItemStyle.Done,
                                                              (s, e) => {
                txt.ResignFirstResponder ();
            });
            doneButton.TintColor = UIColor.Gray;

            UIBarButtonItem goButton = new UIBarButtonItem ("Run", UIBarButtonItemStyle.Done,
                                                              (s, e) => {

                txt.ResignFirstResponder ();
                OnRun ();
            });

            toolbar.SetItems (new UIBarButtonItem[]{doneButton, goButton}, true);

            txt.InputAccessoryView = toolbar;
        }
开发者ID:JackFong,项目名称:NLuaBox,代码行数:23,代码来源:NLuaSampleViewController.cs

示例8: ViewDidLoad

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

			#region UI controls, you could do this in a XIB if you wanted
			saveButton = UIButton.FromType (UIButtonType.RoundedRect);
			saveButton.Frame = new CGRect (10.0, 10.0, 160.0, 50.0);
			saveButton.SetTitle ("UpdateChangeCount", UIControlState.Normal);
			saveButton.Enabled = false;
			
			alertText = new UITextView (new CGRect (175.0, 10.0, 140.0, 50.0)) {
				TextColor = UIColor.Red,
				Editable = false
			};

			docText = new UITextView (new CGRect (10.0, 70.0, 300.0, 150.0)) {
				Editable = true,
				ScrollEnabled = true,
				BackgroundColor = UIColor.FromRGB (224, 255, 255)
			};
			
			// Add the controls to the view
			Add (saveButton);
			Add (docText);
			Add (alertText);
			#endregion

			saveButton.TouchUpInside += (sender, e) => {
				// we're not checking for conflicts or anything, just saving the edited version over the top
				Console.WriteLine ("UpdateChangeCount -> hint for iCloud to save");
				doc.DocumentString = docText.Text;
				alertText.Text = string.Empty;
				doc.UpdateChangeCount (UIDocumentChangeKind.Done);
				docText.ResignFirstResponder ();
			};
			
			// listen for notifications that the document was modified via the server
			NSNotificationCenter.DefaultCenter.AddObserver (this,
				new Selector ("dataReloaded:"),
				new NSString ("monkeyDocumentModified"),
				null
			);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:43,代码来源:MonkeyDocumentViewController.cs

示例9: ViewDidLoad

		public override void ViewDidLoad ()
		{
			// add the inputs to the DialogViewController - bit of a hack :)
			base.ViewDidLoad ();

			var f = TableView.Frame;
			f.Height -= 65;
			f.Y += 65;
			TableView.Frame = f;

			input = new UITextView(new RectangleF(3, 23, 247, 37));
			input.BackgroundColor= UIColor.FromRGB(207,220,255);
			input.Font = UIFont.SystemFontOfSize (16f);
			done = UIButton.FromType (UIButtonType.RoundedRect);
			done.Frame = new RectangleF(255, 23, 60, 37); // 400

			done.SetTitle ("Cloud", UIControlState.Normal);

			// SEND BUTTON 
			done.TouchUpInside += (sender, e) => {
				if (input.Text.Length > 0) {
					Console.WriteLine ("Update icloud kv with\n    " + UIDevice.CurrentDevice.Name+":"+ input.Text);
	
					// add chat to list
					chatSection.Add (new ChatBubble (BubbleType.Left, input.Text));
					// scroll to the end
					var lastIP = NSIndexPath.FromRowSection(chatSection.Count-1, 0);
					TableView.ScrollToRow (lastIP, UITableViewScrollPosition.Bottom, true);
					// update the cloud
					var store = NSUbiquitousKeyValueStore.DefaultStore;
					store.SetString(UIDevice.CurrentDevice.Name, input.Text);
					store.Synchronize ();
					// reset
					input.Text = "";
					input.ResignFirstResponder ();
				}
			};
		}
开发者ID:GSerjo,项目名称:Seminars,代码行数:38,代码来源:BubbleViewController.cs

示例10: EditingEnded

			public override void EditingEnded (UITextView textView)
			{
				if (textView.Text == "")
				{
					textView.Text = _hint;
					editorView.Text = _hint;
					textView.TextColor = UIColor.FromRGB (150, 150, 150);
				} else
				{
					editorView.Text = textView.Text;
				}

				textView.ResignFirstResponder ();
			}
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:14,代码来源:CommentEditorRenderer.cs

示例11: EditingEnded

            public override void EditingEnded(UITextView textView)
            {
                if (textView.Text == "")
                {
                    textView.Text = Placeholder;
                    textView.TextColor = UIColor.LightGray;
                }
				formsEditor.Text = textView.Text;
                textView.ResignFirstResponder();
                UIView view = getRootSuperView(textView);
                textView.BackgroundColor = UIColor.White;
                CoreGraphics.CGRect rect = view.Frame;
                rect.Y += 80;
                view.Frame = rect;
            }
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:15,代码来源:CustomEditorRenderer.cs

示例12: ViewDidLoad

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

            #region UI Controls (you could do this in XIB if you want)
            saveButton = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new RectangleF(10,10,145,40);
            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitle("waiting...", UIControlState.Disabled);
            saveButton.Enabled = false;

            deleteButton = UIButton.FromType(UIButtonType.RoundedRect);
            deleteButton.Frame = new RectangleF(10,150,145,40);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.Enabled = false;

            doneSwitch = new UISwitch();
            doneSwitch.Frame = new RectangleF(185, 30, 145, 50);
            doneSwitch.Enabled = false;
            doneLabel = new UILabel();
            doneLabel.Frame = new RectangleF(200, 10, 145, 15);
            doneLabel.Text = "Done?";

            titleText = new UITextView(new RectangleF(10, 70, 300, 40));
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
            titleText.Editable = true;
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);

            descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
            descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
            descriptionText.Editable = true;
            descriptionText.ScrollEnabled = true;
            descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            // Add the controls to the view
            this.Add(saveButton);
            this.Add(deleteButton);
            this.Add(doneLabel);
            this.Add(doneSwitch);
            //this.Add(descriptionText);   // disabled for Azure demo (for now...)
            this.Add(titleText);
            #endregion

            LoadData ();

            saveButton.TouchUpInside += (sender, e) => {

                task.Title = titleText.Text;
                task.Description = descriptionText.Text;
                task.IsDone = doneSwitch.On;

                // save to Azure
                AzureWebService.UpdateTodo (task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true);
            };

            deleteButton.TouchUpInside += (sender, e) => {

                // save to Azure
                AzureWebService.DeleteTodo (task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true); // doesn't reflect deletion yet
            };
        }
开发者ID:AranHu,项目名称:TaskCloud,代码行数:71,代码来源:TaskScreen.cs

示例13: GetCell

        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell (ekey);
            if (cell == null){
                cell = new MultiLineTableCell (UITableViewCellStyle.Subtitle, ekey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            } else
                RemoveTag (cell, 1);

            if (entry == null)
            {
                entry = new UITextView(new RectangleF(0, 28, cell.ContentView.Bounds.Width, 16 + (20 * (Rows + 1))));
                entry.Font = UIFont.SystemFontOfSize(16);
                entry.Text = Value ?? "";
                entry.BackgroundColor = UIColor.Clear;
                entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
                    UIViewAutoresizing.FlexibleLeftMargin;

                entry.Ended += delegate {
                    Value = entry.Text;

                    entry.ResignFirstResponder();
                };
                entry.Changed += delegate(object sender, EventArgs e) {
                    if(!string.IsNullOrEmpty(entry.Text))
                    {
                        int i = entry.Text.IndexOf("\n", entry.Text.Length -1);
                        if (i > -1)
                        {
                            entry.Text = entry.Text.Substring(0,entry.Text.Length -1);
                            entry.ResignFirstResponder();
                        }
                    }
                    Value = entry.Text;
                };
                ////////////////
            //				entry.Started += delegate {
            //					MultiLineEntryElement focus = null;
            //					foreach (var e in (Parent as Section).Elements){
            //						if (e == this)
            //							focus = this;
            //						else if (focus != null && e is MultiLineEntryElement)
            //							focus = e as MultiLineEntryElement;
            //					}
            //					if (focus != this)
            //						focus.entry.BecomeFirstResponder ();
            //					else
            //						focus.entry.ResignFirstResponder ();
            //
            //				};

            //				entry.Started += delegate {
            //					MultiLineEntryElement self = null;
            //					var returnType = UIReturnKeyType.Default;
            //
            //					foreach (var e in (Parent as Section).Elements){
            //						if (e == this)
            //							self = this;
            //						else if (self != null && e is MultiLineEntryElement)
            //							returnType = UIReturnKeyType.Next;
            //					}
            //				};

                entry.ReturnKeyType = UIReturnKeyType.Done;
            }
            ///////////
            cell.TextLabel.Text = Caption;

            cell.ContentView.AddSubview (entry);
            return cell;
        }
开发者ID:benhorgen,项目名称:monocross_helpers,代码行数:71,代码来源:Elements.cs

示例14: AddKeyboardAccessoryView

        private void AddKeyboardAccessoryView(UITextView textView)
        {
            int toolbarHeight = 44;
            int toolbarWidth = (int)View.Frame.Width;

            var toolbar = new UIToolbar(new Rectangle(0, 0, toolbarWidth, toolbarHeight));
            toolbar.TintColor = AppDelegate.TintColor;
            toolbar.BarStyle = UIBarStyle.Default;

            toolbar.Items = new []
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate {
                    textView.ResignFirstResponder();
                })
            };

            textView.KeyboardAppearance = UIKeyboardAppearance.Light;
            textView.InputAccessoryView = toolbar;
        }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:20,代码来源:ArgumentFormViewController.cs

示例15: GetCell

		public override UITableViewCell GetCell (UITableView tv)
		{
			var cell = tv.DequeueReusableCell (ekey);
			if (cell == null){
				cell = new TableViewCell(UITableViewCellStyle.Default, ekey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
				cell.BackgroundColor = UIColor.White;
			} else 
				RemoveTag (cell, 1);
			
			
			if (entry == null)
			{
				var s = new RectangleF(0, string.IsNullOrEmpty(Caption) ? 10.5f : 32,
				                       cell.ContentView.Bounds.Width, 12 + (20 * (Rows + 1)));
				entry = new UITextView(s);
				
				entry.Font = UIFont.SystemFontOfSize(17);
				entry.Text = Value ?? string.Empty;
				
				entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |UIViewAutoresizing.FlexibleLeftMargin;

				//TODO: Find a way to just curver bottom
				//if (_topItem) { entry.Layer.CornerRadius = 15.0f; }
				if (_bottomItem) { entry.Layer.CornerRadius = 15.0f; }

				entry.Ended += delegate {
					if (entry != null)
					{
						Value = entry.Text;
						
						entry.ResignFirstResponder();
						if (entry.ReturnKeyType == UIReturnKeyType.Go)
						{
							//TODO: Do we submit the form here
							throw new ApplicationException("We need to submit form here");
						}
					}
				};
				entry.Changed += delegate(object sender, EventArgs e) {
					if(!string.IsNullOrEmpty(entry.Text))
					{
						int i = entry.Text.IndexOf("\n", entry.Text.Length -1);
						if (i > -1)
						{
							entry.Text = entry.Text.Substring(0,entry.Text.Length -1); 
							entry.ResignFirstResponder();	
						}
					}
					Value = entry.Text;
				};
				
				entry.ReturnKeyType = UIReturnKeyType.Done;
			}

			cell.TextLabel.Text = Caption; 
			cell.ContentView.AddSubview(entry);
			return cell;
		}
开发者ID:benhorgen,项目名称:MonoTouch.Dialog-AddOns,代码行数:59,代码来源:MultilineEntryElement.cs


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