当文本输入时, 文本框有几中选择用于辅助输入:
textField.clearButtonMode=UITextFieldViewModeWhileEditing;
- typedefenum{
- UITextFieldViewModeNever,//clearbutton永远不出现
- UITextFieldViewModeWhileEditing,//编辑的时候出现
- UITextFieldViewModeUnlessEditing,//未编辑的时候出现
- UITextFieldViewModeAlways//永远都出现
- }UITextFieldViewMode;
弹出的键盘类型也可以辅助快速输入:
textField.keyboardType=UIKeyboardTypeAlphabet;
- typedefenum{
- UIKeyboardTypeDefault,//Defaulttypeforthecurrentinputmethod.
- UIKeyboardTypeASCIICapable,//DisplaysakeyboardwhichcanenterASCIIcharacters,non-ASCIIkeyboardsremainactive
- UIKeyboardTypeNumbersAndPunctuation,//Numbersandassortedpunctuation.
- UIKeyboardTypeURL,//AtypeoptimizedforURLentry(shows./.comprominently).
- UIKeyboardTypeNumberPad,//Anumberpad(0-9).SuitableforPINentry.
- UIKeyboardTypePhonePad,//Aphonepad(1-9,*,0,#,withlettersunderthenumbers).
- UIKeyboardTypeNamePhonePad,//Atypeoptimizedforenteringaperson'snameorphonenumber.
- UIKeyboardTypeEmailAddress,//Atypeoptimizedformultipleemailaddressentry(showsspace@.prominently).
- UIKeyboardTypeAlphabet=UIKeyboardTypeASCIICapable,//Deprecated
- }UIKeyboardType;
键盘的呈现风格:
textField..keyboardAppearance=UIKeyboardAppearanceAlert;
- typedefenum{
- UIKeyboardAppearanceDefault,//Defaultapperanceforthecurrentinputmethod.
- UIKeyboardAppearanceAlert,//Appearancesuitableforusein"alert"scenarios.
- }UIKeyboardAppearance;
键盘对输入字母的控制:
textField.autocapitalizationType=UITextAutocapitalizationTypeAllCharacters;
- typedefenum{
- UITextAutocapitalizationTypeNone,//什么也不做
- UITextAutocapitalizationTypeWords,//单词首字母大写
- UITextAutocapitalizationTypeSentences,//句子首字母大些
- UITextAutocapitalizationTypeAllCharacters,//所有字母大些
- }UITextAutocapitalizationType;
键盘对输入字母自动纠正
textField.autocorrectionType=UITextAutocorrectionTypeYes;
- typedefenum{
- UITextAutocorrectionTypeDefault,
- UITextAutocorrectionTypeNo,
- UITextAutocorrectionTypeYes,
- }UITextAutocorrectionType;
确认键的类型
textField.returnKeyType=UIReturnKeyDone;
- typedefenum{
- UIReturnKeyDefault,
- UIReturnKeyGo,
- UIReturnKeyGoogle,
- UIReturnKeyJoin,
- UIReturnKeyNext,
- UIReturnKeyRoute,
- UIReturnKeySearch,
- UIReturnKeySend,
- UIReturnKeyYahoo,
- UIReturnKeyDone,
- UIReturnKeyEmergencyCall,
- }UIReturnKeyType;
最后一个技巧,也是网上收集,键盘透明以及增加一个按键的应用:
[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(keyboardWillShow:)
- name:UIKeyboardWillShowNotification
- object:nil];
- --------------------
- -(void)keyboardWillShow:(NSNotification*)note{
- //createcustombutton
- UIButton*doneButton=[UIButtonbuttonWithType:UIButtonTypeCustom];
- doneButton.frame=CGRectMake(0,163,106,53);
- doneButton.adjustsImageWhenHighlighted=NO;
- [doneButtonsetImage:[UIImageimageNamed:@"DoneUp.png"]forState:UIControlStateNormal];
- [doneButtonsetImage:[UIImageimageNamed:@"DoneDown.png"]forState:UIControlStateHighlighted];
- [doneButtonaddTarget:selfaction:@selector(doneButton:)forControlEvents:UIControlEventTouchUpInside];
- //locatekeyboardview
- UIWindow*tempWindow=[[[UIApplicationsharedApplication]windows]objectAtIndex:1];
- UIView*keyboard;
- for(inti=0;i<[tempWindow.subviewscount];i++){
- keyboard=[tempWindow.subviewsobjectAtIndex:i];
- //keyboardviewfound;addthecustombuttontoit
- if([[keyboarddescription]hasPrefix:@"<UIKeyboard"]==YES)
- [keyboardaddSubview:doneButton];
- }
- }
当文本输入时, 文本框有几中选择用于辅助输入:
textField.clearButtonMode=UITextFieldViewModeWhileEditing;
- typedefenum{
- UITextFieldViewModeNever,//clearbutton永远不出现
- UITextFieldViewModeWhileEditing,//编辑的时候出现
- UITextFieldViewModeUnlessEditing,//未编辑的时候出现
- UITextFieldViewModeAlways//永远都出现
- }UITextFieldViewMode;
弹出的键盘类型也可以辅助快速输入:
textField.keyboardType=UIKeyboardTypeAlphabet;
- typedefenum{
- UIKeyboardTypeDefault,//Defaulttypeforthecurrentinputmethod.
- UIKeyboardTypeASCIICapable,//DisplaysakeyboardwhichcanenterASCIIcharacters,non-ASCIIkeyboardsremainactive
- UIKeyboardTypeNumbersAndPunctuation,//Numbersandassortedpunctuation.
- UIKeyboardTypeURL,//AtypeoptimizedforURLentry(shows./.comprominently).
- UIKeyboardTypeNumberPad,//Anumberpad(0-9).SuitableforPINentry.
- UIKeyboardTypePhonePad,//Aphonepad(1-9,*,0,#,withlettersunderthenumbers).
- UIKeyboardTypeNamePhonePad,//Atypeoptimizedforenteringaperson'snameorphonenumber.
- UIKeyboardTypeEmailAddress,//Atypeoptimizedformultipleemailaddressentry(showsspace@.prominently).
- UIKeyboardTypeAlphabet=UIKeyboardTypeASCIICapable,//Deprecated
- }UIKeyboardType;
键盘的呈现风格:
textField..keyboardAppearance=UIKeyboardAppearanceAlert;
- typedefenum{
- UIKeyboardAppearanceDefault,//Defaultapperanceforthecurrentinputmethod.
- UIKeyboardAppearanceAlert,//Appearancesuitableforusein"alert"scenarios.
- }UIKeyboardAppearance;
键盘对输入字母的控制:
textField.autocapitalizationType=UITextAutocapitalizationTypeAllCharacters;
- typedefenum{
- UITextAutocapitalizationTypeNone,//什么也不做
- UITextAutocapitalizationTypeWords,//单词首字母大写
- UITextAutocapitalizationTypeSentences,//句子首字母大些
- UITextAutocapitalizationTypeAllCharacters,//所有字母大些
- }UITextAutocapitalizationType;
键盘对输入字母自动纠正
textField.autocorrectionType=UITextAutocorrectionTypeYes;
- typedefenum{
- UITextAutocorrectionTypeDefault,
- UITextAutocorrectionTypeNo,
- UITextAutocorrectionTypeYes,
- }UITextAutocorrectionType;
确认键的类型
textField.returnKeyType=UIReturnKeyDone;
- typedefenum{
- UIReturnKeyDefault,
- UIReturnKeyGo,
- UIReturnKeyGoogle,
- UIReturnKeyJoin,
- UIReturnKeyNext,
- UIReturnKeyRoute,
- UIReturnKeySearch,
- UIReturnKeySend,
- UIReturnKeyYahoo,
- UIReturnKeyDone,
- UIReturnKeyEmergencyCall,
- }UIReturnKeyType;
最后一个技巧,也是网上收集,键盘透明以及增加一个按键的应用:
[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(keyboardWillShow:)
- name:UIKeyboardWillShowNotification
- object:nil];
- --------------------
- -(void)keyboardWillShow:(NSNotification*)note{
- //createcustombutton
- UIButton*doneButton=[UIButtonbuttonWithType:UIButtonTypeCustom];
- doneButton.frame=CGRectMake(0,163,106,53);
- doneButton.adjustsImageWhenHighlighted=NO;
- [doneButtonsetImage:[UIImageimageNamed:@"DoneUp.png"]forState:UIControlStateNormal];
- [doneButtonsetImage:[UIImageimageNamed:@"DoneDown.png"]forState:UIControlStateHighlighted];
- [doneButtonaddTarget:selfaction:@selector(doneButton:)forControlEvents:UIControlEventTouchUpInside];
- //locatekeyboardview
- UIWindow*tempWindow=[[[UIApplicationsharedApplication]windows]objectAtIndex:1];
- UIView*keyboard;
- for(inti=0;i<[tempWindow.subviewscount];i++){
- keyboard=[tempWindow.subviewsobjectAtIndex:i];
- //keyboardviewfound;addthecustombuttontoit
- if([[keyboarddescription]hasPrefix:@"<UIKeyboard"]==YES)
- [keyboardaddSubview:doneButton];
- }
- }