您的位置:首页 > 移动开发 > IOS开发

IOS 关于Text Field设置键盘

2015-11-25 12:18 411 查看
设置数字键盘 : Keyboard Type 选Number Pad

输入显示安全文本 :勾选Secure Text Entry



触摸背景隐藏软键盘

在storyboard或nib,将背景View的Custom Class设置为UIControl,这样才会有Touch事件。

右键背景View,就会出现control栏,建立事件处理方法。

- (IBAction)ViewTouchDown:(id)sender {
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
}


点击Return隐藏自身软键盘
右键UITextField 建立Did End on Exit事件处理方法

- (IBAction)TextFieldDidEndOnExit:(id)sender {
[sender resignFirstResponder];
}


点击Return自动转到下个文本框
先有两个TextField 和button,可以把用户名TextField Return Key 设置成Next,把密码TextField Return Key 设置成Done

先用户名点击Next,焦点跳到密码框中

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

- (IBAction)passwordTextFieldDidEndOnExit:(id)sender {
[sender resignFirstResponder];
[btu_login sendActionsForControlEvents:UIControlEventTouchUpInside];
}


强制使用系统自带键盘

- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier
{
if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) {
return NO;
}
return YES;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Text Field