{"id":581,"date":"2014-06-17T14:45:07","date_gmt":"2014-06-17T06:45:07","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=581"},"modified":"2016-07-15T15:35:53","modified_gmt":"2016-07-15T07:35:53","slug":"ios%e5%bc%80%e5%8f%91%e4%b8%ad%e9%80%80%e5%87%ba%e9%94%ae%e7%9b%98%e7%9a%84%e5%b8%b8%e7%94%a8%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2014\/06\/17\/144507581.html","title":{"rendered":"iOS\u5f00\u53d1\u4e2d\u9000\u51fa\u952e\u76d8\u7684\u5e38\u7528\u65b9\u5f0f"},"content":{"rendered":"<p><strong>1\u3001\u5229\u7528\u952e\u76d8\u7684return\u952e\u9000\u51fa<\/strong><\/p>\n<p>\u8fd9\u79cd\u573a\u666f\u4e00\u822c\u5728TextField\u4e2d\u4f7f\u7528\u6700\u4e3a\u5e38\u89c1\uff0c\u56e0\u4e3aUITextField\u7684\u4ee3\u7406\u4e2d\u6709\u76f8\u5173\u7684\u65b9\u6cd5\uff0c\u56e0\u6b64\u53ea\u8981\u5728\u4ee3\u7406\u4e2d\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n<pre lang=\"objc\" line=\"1\">- (BOOL)textFieldShouldReturn:(UITextField *)textField\n{\n    [textField resignFirstResponder];\n    return YES;\n\n}<\/pre>\n<p><strong>2\u3001\u70b9\u51fb\u7a7a\u767d\u5904\u9000\u51fa\u952e\u76d8<\/strong><\/p>\n<p>\u8be5\u573a\u666f\u4e00\u822c\u6307\u6240\u8c13\u7684\u7a7a\u767d\u5904\u4e3a\u63a7\u5236\u5668\u7684\u57fa\u672cview\u7684\u65f6\u5019\uff0c\u5982\u679cview\u4e0a\u9762\u518d\u6709\u5176\u4ed6\u7684\u89c6\u56fe\uff0c\u6216\u8005\u4f1a\u66f4\u591a\u9ebb\u70e6\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u53ea\u9700\u8981\u5b9e\u73b0\uff1a<\/p>\n<pre lang=\"objc\" line=\"1\">- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event\n{\n    [self.view endEditing:YES];\n\n}<\/pre>\n<p><strong>3\u3001\u521b\u5efa\u624b\u52bf\uff0c\u5229\u7528\u624b\u52bf\u54cd\u5e94\u76f8\u5173\u65b9\u6cd5\u9000\u51fa\u952e\u76d8<\/strong><\/p>\n<pre lang=\"objc\" line=\"1\">UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didScrollViewTaped)];   \n[self.scrollView addGestureRecognizer:tapGesture];\n- (void)didScrollViewTaped\n{\n    [self.scrollView endEditing:YES];\n\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5229\u7528\u952e\u76d8\u7684return\u952e\u9000\u51fa \u8fd9\u79cd\u573a\u666f\u4e00\u822c\u5728TextField\u4e2d\u4f7f\u7528\u6700\u4e3a\u5e38\u89c1\uff0c\u56e0\u4e3aUITextField\u7684\u4ee3\u7406\u4e2d\u6709\u76f8\u5173\u7684\u65b9\u6cd5\uff0c\u56e0\u6b64\u53ea\u8981\u5728\u4ee3\u7406\u4e2d\u5b9e\u73b0\u65b9\u6cd5\uff1a &#8211; (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } 2\u3001\u70b9\u51fb\u7a7a\u767d\u5904\u9000\u51fa\u952e\u76d8 \u8be5\u573a\u666f\u4e00\u822c\u6307\u6240\u8c13\u7684\u7a7a\u767d\u5904\u4e3a\u63a7\u5236\u5668\u7684\u57fa\u672cview\u7684\u65f6\u5019\uff0c\u5982\u679cview\u4e0a\u9762\u518d\u6709\u5176\u4ed6\u7684\u89c6\u56fe\uff0c\u6216\u8005\u4f1a\u66f4\u591a\u9ebb\u70e6\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u53ea\u9700\u8981\u5b9e\u73b0\uff1a &#8211; (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } 3\u3001\u521b\u5efa\u624b\u52bf\uff0c\u5229\u7528\u624b\u52bf\u54cd\u5e94\u76f8\u5173\u65b9\u6cd5\u9000\u51fa\u952e\u76d8 UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didScrollViewTaped)]; [self.scrollView addGestureRecognizer:tapGesture]; &#8211; (void)didScrollViewTaped { [self.scrollView endEditing:YES]; }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[20,17],"class_list":["post-581","post","type-post","status-publish","format-standard","hentry","category-project","tag-basics","tag-skill"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}