我是靠谱客的博主 苹果香水,这篇文章主要介绍IOS 关于Text Field设置键盘,现在分享给大家,希望可以做个参考。

设置数字键盘 : 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]; }


点击Return隐藏自身软键盘

右键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,焦点跳到密码框中

复制代码
1
2
3
- (IBAction)nameTextFieldDidEndOnExit:(id)sender { [self.passwordTF becomeFirstResponder]; }
密码框点击Done,隐藏键盘同时触发btu_login按钮按下。

复制代码
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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部