{"id":167,"date":"2010-02-06T01:19:38","date_gmt":"2010-02-05T16:19:38","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=167"},"modified":"2025-03-12T11:32:11","modified_gmt":"2025-03-12T02:32:11","slug":"dont-want-hide-uitextview-behind-keyboard","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2010\/02\/06\/dont-want-hide-uitextview-behind-keyboard\/","title":{"rendered":"\u753b\u9762\u3044\u3063\u3071\u3044\u306eUITextView\u304c\u30ad\u30fc\u30dc\u30fc\u30c9\u306b\u96a0\u308c\u306a\u3044\u3088\u3046\u306b\u3059\u308b"},"content":{"rendered":"<p>iPad\u3067\u753b\u9762\u3044\u3063\u3071\u3044\u306bUITextView\u3092\u914d\u7f6e\u3059\u308b\u3068\u3001\u5165\u529b\u72b6\u614b\u306b\u306a\u3063\u305f\u969b\u306b\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u51fa\u3066\u304d\u3066\u5165\u529b\u30ab\u30fc\u30bd\u30eb\u304c\u96a0\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u300c\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u8868\u793a\u30fb\u975e\u8868\u793a\u306b\u306a\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3001UITextView\u306e\u9ad8\u3055\u3092\u5909\u3048\u3066\u3042\u3052\u308b\u300d\u3053\u3068\u3067 \u5bfe\u51e6\u53ef\u80fd\u3067\u3059\u3002UICatalog\u306e\u30b5\u30f3\u30d7\u30eb\u304c\u5c11\u3057\u53e4\u304f\u30013.2\u3067\u306fDeprecated\u306b\u306a\u3063\u3066\u3044\u308bUIKeyboardBoundsUserInfoKey\u3092\u4f7f\u3063\u3066\u3044\u305f\u305f\u3081\u3001UIKeyboardFrameEndUserInfoKey\u3092\u4f7f\u3046\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u6050\u3089\u304fiPhone\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre lang=\"objc\" line=\"1\">\n@interface CustomViewController : UIViewController <UITextViewDelegate> {\n    UITextView *_textView; \/\/\u5bfe\u8c61\u3068\u306a\u308b\u30c6\u30ad\u30b9\u30c8\u30d3\u30e5\u30fc\u3002UIViewController\u306e\u30b5\u30d6\u30d3\u30e5\u30fc\u3068\u3057\u3066\u8ffd\u52a0\u3059\u308b\u3002\n}\n@property (nonatomic, retain) IBOutlet UITextView *_textView;\n@end\n\n\n@implementation CustomeViewController\n\n- (void)viewDidLoad {\n    [super viewDidLoad];    \n    \/\/\u89aa\u30d3\u30e5\u30fc\u306e\u9ad8\u3055\u304c\u5909\u66f4\u3055\u308c\u305f\u6642\u306b\u8ffd\u5f93\u3059\u308b\u3088\u3046\u306b\u3059\u308b\n    _textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;\n}\n\n- (void)viewWillAppear:(BOOL)animated {\n    [super viewWillAppear:animated];\n    \n    \/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u8868\u793a\u30fb\u975e\u8868\u793a\u306e\u901a\u77e5\u306e\u958b\u59cb\n    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];\n    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];\n}\n\n- (void)viewDidDisappear:(BOOL)animated {\n    [super viewDidDisappear:animated];\n\n    \/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u8868\u793a\u30fb\u975e\u8868\u793a\u306e\u901a\u77e5\u3092\u7d42\u4e86\n    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];\n    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];\n}\n\n\/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u8868\u793a\u3055\u308c\u305f\u5834\u5408\n- (void)keyboardWillShow:(NSNotification *)aNotification {\n    \/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u306eCGRect\u3092\u53d6\u5f97\n    CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n    keyboardRect = [[self.view superview] convertRect:keyboardRect fromView:nil];\n    \n    \/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u306eanimationDuration\u3092\u53d6\u5f97\n    NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];\n\n    \/\/\u30e1\u30a4\u30f3\u30d3\u30e5\u30fc\u306e\u9ad8\u3055\u3092\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u9ad8\u3055\u5206\u30de\u30a4\u30ca\u30b9\u3057\u305fframe\n    CGRect frame = self.view.frame;\n    frame.size.height -= keyboardRect.size.height;\n\n    \/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3068\u540c\u3058\u9593\u9694\u3067\u30e1\u30a4\u30f3\u30d3\u30e5\u30fc\u306e\u9ad8\u3055\u3092\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3057\u3064\u3064\u5909\u66f4\u3059\u308b\u3002\n    \/\/\u3053\u308c\u3067UITextView\u3082\u8ffd\u5f93\u3057\u3066\u9ad8\u3055\u304c\u5909\u308f\u308b\u3002\n    [UIView beginAnimations:@\"ResizeForKeyboard\" context:nil];\n    [UIView setAnimationDuration:animationDuration];\n    self.view.frame = frame;\n    [UIView commitAnimations];\n}\n\n\/\/\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u975e\u8868\u793a\u306b\u3055\u308c\u305f\u5834\u5408\uff08keyboardWillShow\u3068\u540c\u3058\u3053\u3068\u3092\u9ad8\u3055\u3092+\u3057\u3066\u3084\u3063\u3066\u3044\u308b\u3060\u3051\uff09\n- (void)keyboardWillHide:(NSNotification *)aNotification {\n    CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n    keyboardRect = [[self.view superview] convertRect:keyboardRect fromView:nil];\n\n    NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];\n\n    CGRect frame = self.view.frame;\n    frame.size.height += keyboardRect.size.height;\n\n    [UIView beginAnimations:@\"ResizeForKeyboard\" context:nil];\n    [UIView setAnimationDuration:animationDuration];\n    self.view.frame = frame;\n    [UIView commitAnimations];\n}\n\n@end\n<\/pre>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167&#038;t=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167&#038;text=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167&#038;title=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=%E7%94%BB%E9%9D%A2%E3%81%84%E3%81%A3%E3%81%B1%E3%81%84%E3%81%AEUITextView%E3%81%8C%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%AA%E3%81%84%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F167\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>iPad\u3067\u753b\u9762\u3044\u3063\u3071\u3044\u306bUITextView\u3092\u914d\u7f6e\u3059\u308b\u3068\u3001\u5165\u529b\u72b6\u614b\u306b\u306a\u3063\u305f\u969b\u306b\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u51fa\u3066\u304d\u3066\u5165\u529b\u30ab\u30fc\u30bd\u30eb\u304c\u96a0\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u300c\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u8868\u793a\u30fb\u975e\u8868\u793a\u306b\u306a\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3001UITextView\u306e\u9ad8\u3055\u3092\u5909\u3048\u3066\u3042 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[22],"class_list":["post-167","post","type-post","status-publish","format-standard","hentry","category-1","tag-objective-c"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":8,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":4720,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions\/4720"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}