本文整理汇总了C#中UITextField.BecomeFirstResponder方法的典型用法代码示例。如果您正苦于以下问题:C# UITextField.BecomeFirstResponder方法的具体用法?C# UITextField.BecomeFirstResponder怎么用?C# UITextField.BecomeFirstResponder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITextField
的用法示例。
在下文中一共展示了UITextField.BecomeFirstResponder方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupUI
private void SetupUI ()
{
View.BackgroundColor = UIColor.White;
verseReference = new UITextField {
AutocapitalizationType = UITextAutocapitalizationType.Words,
BackgroundColor = UIColor.Clear,
BorderStyle = UITextBorderStyle.None,
Font = FontConstants.SourceSansProBold (17),
Frame = new RectangleF (0, 0, View.Bounds.Size.Width, 28f),
Placeholder = "Verse"
};
verseReference.BecomeFirstResponder ();
blackLine = new UIView {
BackgroundColor = UIColor.FromPatternImage (UIImage.FromFile (Images.BlackLine)),
Frame = new RectangleF (0, 28, View.Bounds.Width, 3f)
};
textViewDelegate = new ContentTextDelegate ();
verseComments = new UITextView {
Delegate = textViewDelegate,
Font = FontConstants.SourceSansProBold (15),
Frame = new RectangleF (0, 31, View.Bounds.Width, 145f),
KeyboardAppearance = UIKeyboardAppearance.Default,
Text = "Comments",
TextAlignment = UITextAlignment.Left,
TextColor = UIColor.LightGray
};
View.AddSubview (verseReference);
View.AddSubview (blackLine);
View.AddSubview (verseComments);
}
示例2: 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 ();
}
示例3: ComposeTextFieldControl
private UITextField ComposeTextFieldControl(bool secureTextEntry)
{
UITextField textField = new UITextField (new System.Drawing.RectangleF(12f, 45f, 260f, 25f));
textField.BackgroundColor = UIColor.White;
textField.UserInteractionEnabled = true;
textField.AutocorrectionType = UITextAutocorrectionType.No;
textField.AutocapitalizationType = UITextAutocapitalizationType.None;
textField.ReturnKeyType = UIReturnKeyType.Done;
textField.SecureTextEntry = secureTextEntry;
textField.Text = _initEditValue;
textField.Placeholder = _placeHolderValue;
textField.BecomeFirstResponder();
return textField;
}
示例4: LayoutSubviews
public override void LayoutSubviews()
{
// layout the stock UIAlertView control
base.LayoutSubviews ();
// build out the text field
_tf = ComposeTextFieldControl(_secureTextEntry);
// add the text field to the alert view
this.AddSubview(_tf);
// We can only force it to become a First Responder after it has been added to the MainView.
_tf.BecomeFirstResponder();
// shift the contents of the alert view around to accomodate the extra text field
AdjustControlSize();
}
示例5: ActivateEditTextImpl
private void ActivateEditTextImpl()
{
currentActiveEditText = this;
attachedTextField = textField;
UpdateInputTypeImpl();
attachedTextField.Text = text;
attachedTextField.EditingChanged += TextFieldOnValueChanged;
attachedTextField.ShouldChangeCharacters += ShouldChangeCharacters;
attachedTextField.BecomeFirstResponder();
}
示例6: CloseModal
public void CloseModal()
{
if(closing || topModal == null)
return;
closing = true;
NavigationItem.LeftBarButtonItem = null;
var tb = new UITextField(new RectangleF(0,-40,40,40));
if (topModal is UIViewController)
{
var vcv = (topModal as UIViewController).View;
vcv.AddSubview(tb);
tb.BecomeFirstResponder();
tb.ResignFirstResponder();
this.NavigationController.PopViewControllerAnimated (false);
MainView.AddSubview (vcv);
topModal = vcv;
}
var modal = topModal as UIView;
modal.AddSubview(tb);
tb.BecomeFirstResponder();
tb.ResignFirstResponder();
UIView.BeginAnimations ("closeModel");
UIView.SetAnimationDuration (AnimationSpeed);
UIView.SetAnimationCurve(UIViewAnimationCurve.EaseIn);
UIView.SetAnimationDelegate (this);
UIView.SetAnimationDidStopSelector (new Selector ("fadeOutDidFinish"));
modal.Transform = CGAffineTransform.MakeScale (0.2f, 0.2f);
modal.Alpha = 0.5f;
UIView.CommitAnimations ();
}
示例7: ShowPicker
public void ShowPicker()
{
if(PickerShown != null)
PickerShown(this,null);
LayoutSubviews ();
pickerView.BringSubviewToFront(closeBtn);
pickerVisible = true;
var parentView = ViewForPicker ?? this.Superview;
var parentFrame = parentView.Frame;
//closeView = new TapableView(parentView.Bounds);
//closeView.Tapped += delegate{
// HidePicker();
//};
pickerView.Frame = pickerView.Frame.SetLocation(new PointF(0,parentFrame.Height));
UIView.BeginAnimations("slidePickerIn");
UIView.SetAnimationDuration(0.3);
UIView.SetAnimationDelegate(this);
UIView.SetAnimationDidStopSelector (new Selector ("fadeInDidFinish"));
//parentView.AddSubview(closeView);
parentView.AddSubview(pickerView);
var tb = new UITextField(new RectangleF(0,-100,15,25));
//closeView.AddSubview(tb);
tb.BecomeFirstResponder();
tb.ResignFirstResponder();
tb.RemoveFromSuperview();
pickerView.Frame = pickerView.Frame.SetLocation(new PointF(0,parentFrame.Height - pickerView.Frame.Height));
UIView.CommitAnimations();
}
示例8: LoginView
//.........这里部分代码省略.........
Add(GravatarView = new UIImageView(new RectangleF(PointF.Empty, GravatarSize))
{
TranslatesAutoresizingMaskIntoConstraints = false,
Image = UIImage.FromBundle("user-default-avatar"),
});
GravatarView.Layer.CornerRadius = GravatarSize.Width / 2;
GravatarView.Layer.MasksToBounds = true;
DisplayGravatar(xamarinAccountEmail);
AddConstraint(NSLayoutConstraint.Create(
GravatarView,
NSLayoutAttribute.Top,
NSLayoutRelation.Equal,
this,
NSLayoutAttribute.Top,
1f, 90f
));
AddConstraint(NSLayoutConstraint.Create(
GravatarView,
NSLayoutAttribute.CenterX,
NSLayoutRelation.Equal,
this,
NSLayoutAttribute.CenterX,
1f, 0
));
AddConstantSizeConstraints(GravatarView, GravatarSize);
Add(EmailField = new UITextField(new RectangleF(10, 10, 300, 30))
{
BorderStyle = UITextBorderStyle.RoundedRect,
Text = xamarinAccountEmail,
TranslatesAutoresizingMaskIntoConstraints = false,
Delegate = new EmailFieldDelegate()
});
AddConstraint(NSLayoutConstraint.Create(
EmailField,
NSLayoutAttribute.Top,
NSLayoutRelation.Equal,
GravatarView,
NSLayoutAttribute.Bottom,
1f, 30f
));
AddConstraint(NSLayoutConstraint.Create(
EmailField,
NSLayoutAttribute.CenterX,
NSLayoutRelation.Equal,
GravatarView,
NSLayoutAttribute.CenterX,
1f, 0
));
var textSize = new NSString("hello").StringSize(UIFont.SystemFontOfSize(12f));
AddConstantSizeConstraints(EmailField, new SizeF(260, textSize.Height + 16));
Add(PasswordField = new UITextField(new RectangleF(10, 10, 300, 30))
{
BorderStyle = UITextBorderStyle.RoundedRect,
SecureTextEntry = true,
TranslatesAutoresizingMaskIntoConstraints = false,
ReturnKeyType = UIReturnKeyType.Go,
Placeholder = "Password"
});
AddConstraint(NSLayoutConstraint.Create(
PasswordField,
NSLayoutAttribute.Top,
NSLayoutRelation.Equal,
EmailField,
NSLayoutAttribute.Bottom,
1f, 10f
));
AddConstraint(NSLayoutConstraint.Create(
PasswordField,
NSLayoutAttribute.CenterX,
NSLayoutRelation.Equal,
EmailField,
NSLayoutAttribute.CenterX,
1f, 0
));
AddConstantSizeConstraints(PasswordField, new SizeF(260, textSize.Height + 16));
PasswordField.ShouldReturn = field =>
{
field.ResignFirstResponder();
UserDidLogin(this);
return true;
};
PasswordField.BecomeFirstResponder();
}
示例9: setLogoutView
// Create user logout View
public void setLogoutView(){
logoutVIew.Frame = new CGRect (0.0f, 0.0f, 275, 200);
logoutVIew.BackgroundColor = UIColor.White;
titleName = new UILabel (new CGRect(0, 10, logoutVIew.Bounds.Size.Width , 30));
titleName.TextAlignment = UITextAlignment.Center;
Console.WriteLine (titleName.Text);
titleName.TextColor = UIColor.FromRGB(65, 64, 65);
userEmail = new UILabel (new CGRect(0, titleName.Bounds.Y + titleName.Bounds.Size.Height + 15, logoutVIew.Bounds.Size.Width , 25));
userEmail.TextAlignment = UITextAlignment.Center;
userEmail.TextColor = UIColor.FromRGB(26, 100, 51);
// UIFont EmailFont = new UIFont ();
userEmail.MinimumFontSize = 8.0f;
userEmail.AdjustsFontSizeToFitWidth = true;
affView = new UIView(new CGRect(10, 80, logoutVIew.Bounds.Size.Width - 20 , 35));
affView.BackgroundColor = UIColor.Clear;
Appdata.setViewBorder (affView);
downArrow = new UIImageView (new CGRect (affView.Frame.Size.Width - 35, 2, 30, 30));
downArrow.Image = UIImage.FromFile ("down_arrow.png");
affName = new UITextField (new CGRect(0, 5, affView.Frame.Size.Width, 25));
affName.Hidden = true;
affiliateName = new UIButton(new CGRect(5, 5, affView.Frame.Size.Width - 35 , 25));
affiliateName.SetTitle ("Taran Test Affiliate 11", UIControlState.Normal);
affiliateName.SetTitleColor (UIColor.Black, UIControlState.Normal);
affiliateName.TitleLabel.AdjustsFontSizeToFitWidth = true;
affiliateName.TouchUpInside += (object sender, EventArgs e) => {
affName.BecomeFirstResponder();
};
affView.AddSubview (affName);
affView.AddSubview (affiliateName);
affView.AddSubview (downArrow);
editbutton = new UIButton (new CGRect (10, logoutVIew.Bounds.Size.Height-50, 100, 40));
editbutton.SetTitle ("Edit", UIControlState.Normal);
editbutton.BackgroundColor = UIColor.FromRGB(17,115,180);
editbutton.SetTitleColor (UIColor.White, UIControlState.Normal);
Appdata.setButtonBorder (editbutton);
logoutButton = new UIButton (new CGRect (logoutVIew.Bounds.Size.Width-110, logoutVIew.Bounds.Size.Height-50, 100, 40));
logoutButton.SetTitle ("Logout", UIControlState.Normal);
logoutButton.BackgroundColor = Appdata.buttonBackgroundColor;
logoutButton.SetTitleColor (UIColor.White, UIControlState.Normal);
Appdata.setButtonBorder (logoutButton);
logoutButton.TouchUpInside += (object sender, EventArgs e) => {
affName.ResignFirstResponder ();
};
editbutton.TouchUpInside += (object sender, EventArgs e) => {
Console.WriteLine("Edit button Tap");
affName.ResignFirstResponder ();
};
logoutVIew.Layer.CornerRadius = 10.0f;
logoutVIew.Layer.BorderWidth = 1.0f;
logoutVIew.Layer.BorderColor = UIColor.Gray.CGColor;
logoutVIew.Layer.MasksToBounds = true;
logoutVIew.ClipsToBounds = true;
// loadAffiliatePickerView ();
logoutVIew.AddSubview (titleName);
logoutVIew.AddSubview (userEmail);
logoutVIew.AddSubview (affView);
// logoutVIew.AddSubview (affiliateName);
logoutVIew.AddSubview (logoutButton);
logoutVIew.AddSubview (editbutton);
// mainView.AddSubview (logoutVIew);
}
示例10: BuildLoginScreen
// public override void ViewDidUnload ()
// {
// base.ViewDidUnload ();
//
// // Clear any references to subviews of the main view in order to
// // allow the Garbage Collector to collect them sooner.
// //
// // e.g. myOutlet.Dispose (); myOutlet = null;
//
// ReleaseDesignerOutlets ();
// }
//
// public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
// {
// // Return true for supported orientations
// return true;
// }
public void BuildLoginScreen()
{
//create a login text box and password text box and button
UIView[] arrItems = new UIView[6];
UILabel lblLogin = new UILabel();
lblLogin.Tag = 500;
lblLogin.Frame = new RectangleF(120f,100f,100f,30f);
lblLogin.Text = "Login Name:";
arrItems[0] = lblLogin;
UITextField txtLogin = new UITextField();
txtLogin.BorderStyle = UITextBorderStyle.RoundedRect;
txtLogin.Tag = 1000;
txtLogin.Frame = new RectangleF(230f,100f,200f,30f);
txtLogin.AutocapitalizationType = UITextAutocapitalizationType.None;
arrItems[1] = txtLogin;
UILabel lblPass = new UILabel();
lblPass.Tag = 1500;
lblPass.Frame = new RectangleF(120f,150f,100f,30f);
lblPass.Text = "Password:";
arrItems[2] = lblPass;
UITextField txtPass = new UITextField();
txtPass.BorderStyle = UITextBorderStyle.RoundedRect;
txtPass.Tag = 2000;
txtPass.Frame = new RectangleF(230f,150f,200f,30f);
txtPass.AutocapitalizationType = UITextAutocapitalizationType.None;
txtPass.SecureTextEntry = true;
//txtPass.EnablesReturnKeyAutomatically = true;
txtPass.AllTouchEvents += (sender, e) => {DetectEnterKey(sender,e);};
arrItems[3] = txtPass;
var btnLogin = UIButton.FromType(UIButtonType.RoundedRect);
btnLogin.Frame = new RectangleF(200f,200f,100f,30f);
btnLogin.SetTitle("Login", UIControlState.Normal);
btnLogin.TouchUpInside += (sender,e) => {LogintoSCMS(sender, e);};
arrItems[4] = btnLogin;
UILabel hfLoggedIn = new UILabel();
hfLoggedIn.Tag = 3000;
hfLoggedIn.Frame = new RectangleF(120f,200f,100f,30f);
hfLoggedIn.Hidden = true;
arrItems[5] = hfLoggedIn;
View.AddSubviews(arrItems);
txtLogin.BecomeFirstResponder();
}
示例11: GetCell
public override UITableViewCell GetCell(UITableView tv)
{
Value = FormatDate(DateValue);
var cell = tv.DequeueReusableCell (CellKey);
if (cell == null){
cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
} else
RemoveTag (cell, 1);
if (entry == null){
SizeF size = ComputeEntryPosition (tv, cell);
float yOffset = (cell.ContentView.Bounds.Height - size.Height) / 2 - 1;
float width = cell.ContentView.Bounds.Width - size.Width - 5;
entry = CreateTextField (new RectangleF (size.Width, yOffset, width, size.Height));
dummyEntry = CreateTextField (new RectangleF (size.Width, yOffset, width, size.Height));
entry.Alpha = 0;
dummyEntry.ShouldBeginEditing = delegate {
DateValue = (DateValue ?? DefaultDateValue);
entry.BecomeFirstResponder();
return (false);
};
dummyEntry.ShouldClear = delegate {
DateValue = null;
return (true);
};
dummyEntry.EditingChanged += delegate(object sender, EventArgs e) {
if (string.IsNullOrEmpty((sender as UITextField).Text))
{
dummyEntry.Text = FormatDate(DateValue);
dummyEntry.ClearButtonMode = UITextFieldViewMode.Never;
entry.ResignFirstResponder();
}
};
datePicker = CreatePicker();
entry.InputView = datePicker;
}
if (becomeResponder){
entry.BecomeFirstResponder ();
becomeResponder = false;
}
cell.TextLabel.Text = Caption;
cell.ContentView.AddSubview (entry);
cell.ContentView.AddSubview (dummyEntry);
return cell;
}
示例12: EditingBegan
partial void EditingBegan(UITextField sender)
{
sender.BecomeFirstResponder();
}
示例13: InitializePropsUI
string InitializePropsUI()
{
var help = Source as IHelpful;
var helpText = "";
var q = from t in SourceType.GetProperties ()
where t.DeclaringType == SourceType && t.CanWrite
select t;
var props = q.ToArray ();
var rows = new List<Row> ();
foreach (var p in props) {
var ignoreAttrs = p.GetCustomAttributes (typeof(IgnoreAttribute), true);
if (ignoreAttrs.Length > 0)
continue;
var isEmail = p.GetCustomAttributes (typeof(EmailInputAttribute), true).Length > 0;
if (!isEmail && p.Name == "Email") {
isEmail = true;
}
var isChooseEmail = p.GetCustomAttributes (typeof(ChooseEmailInputAttribute), true).Length > 0;
var title = Theme.GetTitle (p.Name);
if (help != null) {
var h = help.HelpForProperty (p.Name);
if (h != "") {
helpText += title + " " + h + "\n";
}
}
var label = new UILabel { BackgroundColor = UIColor.Black, TextColor = Lcars.ComponentColors[LcarsComponentType.CriticalFunction], Text = title, TextAlignment = UITextAlignment.Right, BaselineAdjustment = UIBaselineAdjustment.AlignBaselines, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = true };
var row = new Row { Property = p };
rows.Add (row);
row.Label = label;
UIKeyboardType kbd = UIKeyboardType.Default;
if (isEmail || isChooseEmail) {
kbd = UIKeyboardType.EmailAddress;
} else if (p.Name == "Url") {
kbd = UIKeyboardType.Url;
} else if (p.PropertyType == typeof(int)) {
kbd = UIKeyboardType.NumberPad;
}
var init = p.GetValue (Source, null);
var text = new UITextField { Placeholder = title, BackgroundColor = UIColor.Black, TextColor = UIColor.White, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = false, AutocapitalizationType = UITextAutocapitalizationType.None, KeyboardType = kbd, Text = init != null ? init.ToString () : "" };
row.Text = text;
if (p.Name.ToLowerInvariant ().IndexOf ("password") >= 0) {
text.SecureTextEntry = true;
text.AutocorrectionType = UITextAutocorrectionType.No;
}
if (p.Name != "Search") {
text.AutocorrectionType = UITextAutocorrectionType.No;
}
if (text.Text.Length == 0 && !isChooseEmail) {
text.BecomeFirstResponder ();
}
label.Hidden = text.Text.Length == 0;
if (isChooseEmail) {
text.EditingDidBegin += delegate {
try {
bool hasPeople = false;
using (var adds = new ABAddressBook ()) {
foreach (var pe in adds.GetPeople ()) {
var es = pe.GetEmails ();
if (es.Count > 0) {
hasPeople = true;
break;
}
}
}
if (hasPeople) {
Sounds.PlayBeep ();
var em = new ChooseEmail ();
em.EmailSelected += emailAddress =>
{
text.Text = emailAddress;
UpdateUI ();
};
App.Inst.ShowDialog (em);
NSTimer.CreateScheduledTimer (TimeSpan.FromMilliseconds (30), delegate {
try {
HideKeyBoard (this);
} catch (Exception err) {
Log.Error (err);
}
});
}
} catch (Exception error) {
Log.Error (error);
}
};
}
//.........这里部分代码省略.........
示例14: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
//var native = (UITextField)this.Control;
if (native == null)
{
source = e.NewElement as MyEntry;
var control = (MyEntry)this.Element;
native = this.Control as UITextField;
// INIT defaults
rules = source.Mask;
FormatCharacters = source.FormatCharacters.ToCharArray();
// Events
//if (FormatCharacters != null && String.IsNullOrEmpty(source.Text) == false) {
// ApplyDefaultRule ();
//}
SetFont(control);
SetTextAlignment(control);
SetBorder(control);
SetPlaceholderTextColor(control);
ResizeHeight();
native.ShouldChangeCharacters += new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString)
{
native.BecomeFirstResponder();
if (source.MaxLength > 0)
{
var newlength = source.Text.Length + replacementString.Length - range.Length;
return newlength <= source.MaxLength;
}
if (source.Locked)
{
return false;
}
if (source.Locked == false && source.Mask != null)
{
source.Delete = false;
source.SelectionStart = textField.GetOffsetFromPosition(textField.BeginningOfDocument, textField.SelectedTextRange.Start);
source.SelectionEnd = textField.GetOffsetFromPosition(textField.BeginningOfDocument, textField.SelectedTextRange.End);
source.TextLength = native.Text.Length;
}
if (source.Mask != null)
{
source.Delete = false;
if (replacementString == "")
{
source.Delete = true;
}
source.SelectionStart = textField.GetOffsetFromPosition(textField.BeginningOfDocument, textField.SelectedTextRange.Start);
source.SelectionEnd = textField.GetOffsetFromPosition(textField.BeginningOfDocument, textField.SelectedTextRange.End);
source.TextLength = native.Text.Length;
}
return true;
});
//SetNativeControl(native);
}
}