设置数字键盘 : Keyboard Type 选Number Pad
输入显示安全文本 :勾选Secure Text Entry
触摸背景隐藏软键盘
在storyboard或nib,将背景View的Custom Class设置为UIControl,这样才会有Touch事件。
右键背景View,就会出现control栏,建立事件处理方法。
复制代码
1
2
3- (IBAction)ViewTouchDown:(id)sender { [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; }
右键UITextField 建立Did End on Exit事件处理方法
复制代码
1
2
3- (IBAction)TextFieldDidEndOnExit:(id)sender { [sender resignFirstResponder]; }
点击Return自动转到下个文本框
先有两个TextField 和button,可以把用户名TextField Return Key 设置成Next,把密码TextField Return Key 设置成Done
先用户名点击Next,焦点跳到密码框中
复制代码
密码框点击Done,隐藏键盘同时触发btu_login按钮按下。
1
2
3- (IBAction)nameTextFieldDidEndOnExit:(id)sender { [self.passwordTF becomeFirstResponder]; }
复制代码
1
2
3
4- (IBAction)passwordTextFieldDidEndOnExit:(id)sender { [sender resignFirstResponder]; [btu_login sendActionsForControlEvents:UIControlEventTouchUpInside]; }
强制使用系统自带键盘
复制代码
1
2
3
4
5
6
7- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier { if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) { return NO; } return YES; }
最后
以上就是苹果香水最近收集整理的关于IOS 关于Text Field设置键盘的全部内容,更多相关IOS内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复