{"id":560,"date":"2018-02-23T23:40:02","date_gmt":"2018-02-23T15:40:02","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/ios%e8%be%93%e5%85%a5%e7%b1%bb%e5%9e%8b-%e6%96%87%e6%9c%ac%e5%ad%97%e6%ae%b5text-fields\/"},"modified":"2018-02-23T23:40:02","modified_gmt":"2018-02-23T15:40:02","slug":"ios%e8%be%93%e5%85%a5%e7%b1%bb%e5%9e%8b-%e6%96%87%e6%9c%ac%e5%ad%97%e6%ae%b5text-fields","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=560","title":{"rendered":"iOS\u8f93\u5165\u7c7b\u578b-\u6587\u672c\u5b57\u6bb5(Text Fields)"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h2>\u4e3a\u4ec0\u4e48\u4f7f\u7528\u4e0d\u540c\u7684\u8f93\u5165\u7c7b\u578b\uff1f<\/h2>\n<p>\u952e\u76d8\u8f93\u5165\u7684\u7c7b\u578b\u5e2e\u52a9\u6211\u4eec\u4ece\u7528\u6237\u83b7\u53d6\u5fc5\u9700\u7684\u8f93\u5165\u3002<\/p>\n<p>\u5b83\u79fb\u9664\u4e0d\u9700\u8981\u7684\u952e\uff0c\u5e76\u5305\u62ec\u6240\u9700\u7684\u90e8\u5206\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u00a0UITextField\u00a0\u7684\u952e\u76d8\u5c5e\u6027\u8bbe\u7f6e\u8f93\u5165\u7684\u7c7b\u578b\u3002<\/p>\n<ul>\n<li>\u5982\uff1a\u6587\u672c\u5b57\u6bb5\uff08 textField\uff09\u3002 \u00a0keyboardType = UIKeyboardTypeDefault<\/li>\n<\/ul>\n<p>\u952e\u76d8\u8f93\u5165\u7c7b\u578b<\/p>\n<table class=\"reference\">\n<tbody>\n<tr>\n<th>\u8f93\u5165\u7684\u7c7b\u578b<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeASCIICapable<\/td>\n<td>\u952e\u76d8\u5305\u62ec\u6240\u6709\u6807\u51c6\u7684\u00a0ASCII\u00a0\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeNumbersAndPunctuation<\/td>\n<td>\u952e\u76d8\u663e\u793a\u6570\u5b57\u548c\u6807\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeURL<\/td>\n<td>\u952e\u76d8\u7684\u00a0URL\u00a0\u9879\u4f18\u5316\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeNumberPad<\/td>\n<td>\u952e\u76d8\u7528\u4e8e\u00a0PIN\u00a0\u8f93\u5165\u548c\u663e\u793a\u4e00\u4e2a\u6570\u5b57\u952e\u76d8\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypePhonePad<\/td>\n<td>\u952e\u76d8\u5bf9\u8f93\u5165\u7535\u8bdd\u53f7\u7801\u8fdb\u884c\u4e86\u4f18\u5316\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeNamePhonePad<\/td>\n<td>\u952e\u76d8\u7528\u4e8e\u8f93\u5165\u59d3\u540d\u6216\u7535\u8bdd\u53f7\u7801\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeEmailAddress<\/td>\n<td>\u952e\u76d8\u5bf9\u8f93\u5165\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u7684\u4f18\u5316\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeDecimalPad<\/td>\n<td>\u952e\u76d8\u7528\u6765\u8f93\u5165\u5341\u8fdb\u5236\u6570\u5b57\u3002<\/td>\n<\/tr>\n<tr>\n<td>UIKeyboardTypeTwitter<\/td>\n<td>\u952e\u76d8\u5bf9\u00a0twitter @\u00a0\u548c\u00a0#\u00a0\u7b26\u53f7\u8fdb\u884c\u4e86\u4f18\u5316\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u6dfb\u52a0\u81ea\u5b9a\u4e49\u65b9\u6cd5\u00a0addTextFieldWithDifferentKeyboard<\/h2>\n<pre>-(void) addTextFieldWithDifferentKeyboard{\n\n   UITextField *textField1= [[UITextField alloc]initWithFrame: \n   CGRectMake(20, 50, 280, 30)];\n   textField1.delegate = self;\n   textField1.borderStyle = UITextBorderStyleRoundedRect;\n   textField1.placeholder = @\"Default Keyboard\";\n   [self.view addSubview:textField1];\n\n   UITextField *textField2 = [[UITextField alloc]initWithFrame:\n   CGRectMake(20, 100, 280, 30)];\n   textField2.delegate = self;\n   textField2.borderStyle = UITextBorderStyleRoundedRect;\n   textField2.keyboardType = UIKeyboardTypeASCIICapable;\n   textField2.placeholder = @\"ASCII keyboard\";\n   [self.view addSubview:textField2];\n\n   UITextField *textField3 = [[UITextField alloc]initWithFrame:\n   CGRectMake(20, 150, 280, 30)];\n   textField3.delegate = self;\n   textField3.borderStyle = UITextBorderStyleRoundedRect;\n   textField3.keyboardType = UIKeyboardTypePhonePad;\n   textField3.placeholder = @\"Phone pad keyboard\";\n   [self.view addSubview:textField3];\n\n   UITextField *textField4 = [[UITextField alloc]initWithFrame:\n   CGRectMake(20, 200, 280, 30)];\n   textField4.delegate = self;\n   textField4.borderStyle = UITextBorderStyleRoundedRect;\n   textField4.keyboardType = UIKeyboardTypeDecimalPad;\n   textField4.placeholder = @\"Decimal pad keyboard\";\n   [self.view addSubview:textField4];\n\n   UITextField *textField5= [[UITextField alloc]initWithFrame:\n   CGRectMake(20, 250, 280, 30)];\n   textField5.delegate = self;\n   textField5.borderStyle = UITextBorderStyleRoundedRect;\n   textField5.keyboardType = UIKeyboardTypeEmailAddress;\n   textField5.placeholder = @\"Email keyboard\";\n   [self.view addSubview:textField5];\n\n   UITextField *textField6= [[UITextField alloc]initWithFrame:\n   CGRectMake(20, 300, 280, 30)];\n   textField6.delegate = self;\n   textField6.borderStyle = UITextBorderStyleRoundedRect;\n   textField6.keyboardType = UIKeyboardTypeURL;\n   textField6.placeholder = @\"URL keyboard\";\n   [self.view addSubview:textField6];\n}<\/pre>\n<p>\u5728\u00a0ViewController.m\u00a0\u4e2d\u66f4\u65b0\u00a0viewDidLoad\uff0c\u5982\u4e0b\u6240\u793a<\/p>\n<pre>(void)viewDidLoad\n{\n   [super viewDidLoad];\n   \/\/The custom method to create textfield with different keyboard input\n   [self addTextFieldWithDifferentKeyboard];\n   \/\/Do any additional setup after loading the view, typically from a nib\n}<\/pre>\n<h2>\u8f93\u51fa<\/h2>\n<hr>\n<p>\u73b0\u5728\u5f53\u6211\u4eec\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u65f6\u6211\u4eec\u5c31\u4f1a\u5f97\u5230\u4e0b\u9762\u7684\u8f93\u51fa:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"input_types_text_fields\" src=\"https:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/input_types_text_fields.jpg\" width=\"203\" height=\"397\" data-pinit=\"registered\"><\/p>\n<p>\u9009\u62e9\u4e0d\u540c\u7684\u6587\u672c\u533a\u57df\u6211\u4eec\u5c06\u770b\u5230\u4e0d\u540c\u7684\u952e\u76d8\u3002<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">\u4e3a\u4ec0\u4e48\u4f7f\u7528\u4e0d\u540c\u7684\u8f93\u5165\u7c7b\u578b\uff1f \u952e\u76d8\u8f93\u5165\u7684\u7c7b\u578b\u5e2e\u52a9\u6211\u4eec\u4ece\u7528\u6237\u83b7\u53d6\u5fc5\u9700\u7684\u8f93\u5165\u3002 \u5b83\u79fb\u9664\u4e0d\u9700\u8981\u7684\u952e&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=560\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,26],"tags":[74,93],"class_list":["post-560","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobile","tag-ios","tag-mobile","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=560"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/560\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}