{"id":783,"date":"2012-02-12T18:54:11","date_gmt":"2012-02-12T09:54:11","guid":{"rendered":"http:\/\/redwing.moo.jp\/cocoa\/?p=783"},"modified":"2013-07-24T22:13:33","modified_gmt":"2013-07-24T13:13:33","slug":"%e3%82%ad%e3%83%bc%e3%83%9c%e3%83%bc%e3%83%89%e3%81%ab%e5%85%a5%e5%8a%9b%e9%a0%98%e5%9f%9f%e3%81%8c%e9%87%8d%e3%81%aa%e3%82%89%e3%81%aa%e3%81%84%e3%82%88%e3%81%86%e3%81%ab%e3%81%99%e3%82%8b%e6%96%b9","status":"publish","type":"post","link":"https:\/\/redwing.moo.jp\/cocoa\/archives\/783","title":{"rendered":"\u30ad\u30fc\u30dc\u30fc\u30c9\u306b\u5165\u529b\u9818\u57df\u304c\u91cd\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u4ee5\u4e0b\u306e\u69d8\u306a\u30c6\u30fc\u30d6\u30eb \u30d3\u30e5\u30fc\u3092\u30c7\u30b6\u30a4\u30f3\u3057\u305f\u3068\u3057\u307e\u3059\u3002<br \/>\n\u30c6\u30fc\u30d6\u30eb\u306e\u30bb\u30eb\u306b\u306f\u30c6\u30ad\u30b9\u30c8 \u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u914d\u7f6e\u3055\u308c\u3066\u304a\u308a\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u304b\u3089\u306e\u5165\u529b\u304c\u53ef\u80fd\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u30dc\u30bf\u30f310\u306e\u30bf\u30a4\u30c8\u30eb\u884c\u306a\u3069\u306b\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u3092\u884c\u304a\u3046\u3068\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u79fb\u52d5\u3059\u308b\u3068\u3001<strong>\u753b\u9762\u4e0b\u90e8\u304b\u3089\u8868\u793a\u3055\u308c\u308b\u30ad\u30fc\u30dc\u30fc\u30c9\u3067\u5165\u529b\u9818\u57df\u304c\u96a0\u3055\u308c\u3066\u3057\u307e\u3046<\/strong>\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard00.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard00-300x234.png\" alt=\"\" title=\"table_keyboard00\" width=\"300\" height=\"234\" class=\"alignnone size-medium wp-image-868\" srcset=\"https:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard00-300x234.png 300w, https:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard00.png 540w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u305d\u3053\u3067\u5165\u529b\u9818\u57df\u304c\u91cd\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u5f15\u3063\u5f35\u308a\u4e0a\u3052\u307e\u3059\u3002\uff08\u8868\u73fe\u304c\u3044\u307e\u3044\u3061\u3067\u3059\u304c\u3001\u901a\u5e38\u306e\u30b9\u30af\u30ed\u30fc\u30eb\u3067\u306f\u79fb\u52d5\u3067\u304d\u306a\u3044\u4f4d\u7f6e\u306b\u30bb\u30eb\u3092\u4e0a\u3052\u4e0b\u3052\u3057\u307e\u3059\u3002\uff09<br \/>\n\u3053\u306e\u3088\u3046\u306a\u8868\u793a\u306f\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8868\u793a\u3001\u975e\u8868\u793a\u6642\u306b <strong>UITableView \u306e UIEdgeInsets \u306e\u5024\u3092\u8abf\u6574\u3059\u308b\u3053\u3068\u3067\u3001\u7de8\u96c6\u4e2d\u30bb\u30eb\u3092\u753b\u9762\u4e2d\u592e\u3078\u79fb\u52d5\u3055\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd<\/strong>\u3067\u3059\u3002<br \/>\n\u3042\u3068\u3001iOS 5 \u3067\u306f\u3001\u65e5\u672c\u8a9e\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u4e0a\u90e8\u306b\u4e88\u6e2c\u5909\u63db\u5019\u88dc\u304c\u8868\u793a\u3055\u308c\u308b\u4ed5\u69d8\u3068\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u8003\u616e\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard01-290x300.png\" alt=\"\" title=\"table_keyboard01\" width=\"290\" height=\"300\" class=\"alignnone size-medium wp-image-869\" srcset=\"https:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard01-290x300.png 290w, https:\/\/redwing.moo.jp\/cocoa\/wp-content\/uploads\/table_keyboard01.png 512w\" sizes=\"auto, (max-width: 290px) 100vw, 290px\" \/><\/a><\/p>\n<p>\u624b\u9806\u306f\u3001\u4ee5\u4e0b\u306e\u901a\u308a<br \/>\n1. UITableViewController \u3067\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u901a\u77e5\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<br \/>\n2. \u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8868\u793a\u3001\u975e\u8868\u793a\u306b UITableView \u306e UIEdgeInsets \u306e\u5024\u3092\u8abf\u6574\u3059\u308b\u3053\u3068\u3067\u3001\u7de8\u96c6\u4e2d\u30bb\u30eb\u3092\u753b\u9762\u4e2d\u592e\u3078\u79fb\u52d5\u3055\u305b\u308b<\/p>\n<pre lang=\"objc\" line=\"1\">\r\n- (id)initWithStyle:(UITableViewStyle)style\r\n{\r\n    self = [super initWithStyle:style];\r\n    if (self) {\r\n        \/\/ Custom initialization\r\n       \r\n        \/\/ \u30bd\u30d5\u30c8\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8868\u793a\u3001\u975e\u8868\u793a\u306e\u901a\u77e5\u3092\u767b\u9332\u3059\u308b\r\n        NSNotificationCenter *center;\r\n        center = [NSNotificationCenter defaultCenter];\r\n        [center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];\r\n        [center addObserver:self selector:@selector(keybaordWillHide:) name:UIKeyboardWillHideNotification object:nil];\r\n    }\r\n    \r\n    return self;\r\n}\r\n\r\n- (void)dealloc\r\n{\r\n    \/\/ \u30bd\u30d5\u30c8\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8868\u793a\u3001\u975e\u8868\u793a\u306e\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b\r\n    NSNotificationCenter *center;\r\n    center = [NSNotificationCenter defaultCenter];\r\n    [center removeObserver:self name:UIKeyboardWillShowNotification object:nil];\r\n    [center removeObserver:self name:UIKeyboardWillHideNotification object:nil];\r\n    \r\n    [super dealloc];\r\n}\r\n\r\n#pragma mark -\r\n#pragma mark Software Keyboard Mthods\r\n\r\n- (void)keyboardWillShow:(NSNotification*)notification\r\n{\r\n    NSDictionary *userInfo;\r\n    userInfo = [notification userInfo];\r\n    \r\n    \/\/ 1. \u30ad\u30fc\u30dc\u30fc\u30c9\u306e top \u3092\u53d6\u5f97\u3059\u308b\r\n    CGRect keyboardFrame;\r\n    keyboardFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\r\n    \r\n    CGFloat keyboardTop = (APP_CONTENT_HEIGHT) - (keyboardFrame.size.height + 55.f );   \/\/ 55.f:\u4e88\u6e2c\u5909\u63db\u9818\u57df\u306e\u9ad8\u3055\r\n    \r\n    \r\n    \/\/ 2. \u7de8\u96c6\u4e2d\u30bb\u30eb\u306e bottom \u3092\u53d6\u5f97\u3059\u308b\r\n    \/\/ \u30c6\u30fc\u30d6\u30eb \u30d3\u30e5\u30fc\u306f\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8003\u616e\u3059\u308b\u3053\u3068\r\n    UITableViewCell *cell;\r\n    cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath_.row \r\n                                                                    inSection:indexPath_.section]];\r\n    CGRect cellFrame;\r\n    cellFrame = cell.frame;\r\n    \r\n    CGPoint offset = CGPointZero;\r\n    offset =  self.tableView.contentOffset;  \r\n    \r\n    CGRect cellRectOrigin = CGRectZero;    \r\n    cellRectOrigin.origin.x = cellFrame.origin.x - offset.x;  \r\n    cellRectOrigin.origin.y = cellFrame.origin.y - offset.y; \r\n\r\n    CGFloat cellBottom = cellRectOrigin.origin.y + cellFrame.size.height + 30.f;   \/\/ 30.f:\u30de\u30fc\u30b8\u30f3\r\n\r\n\r\n    \/\/ \u7de8\u96c6\u4e2d\u30bb\u30eb\u306e bottom \u304c\u30ad\u30fc\u30dc\u30fc\u30c9\u306e top \u3088\u308a\u4e0a\u306b\u3042\u308b\u5834\u5408\u3001\r\n    \/\/ \u30ad\u30fc\u30dc\u30fc\u30c9\u306b\u96a0\u308c\u306a\u3044\u3088\u3046\u4f4d\u7f6e\u3092\u8abf\u6574\u3059\u308b\u51e6\u7406\u5bfe\u8c61\u5916\u3068\u3059\u308b\r\n    if (cellBottom < keyboardTop) {\r\n        return;\r\n    }\r\n\r\n    \r\n    \/\/ 3. \u7de8\u96c6\u4e2d\u30bb\u30eb\u3068\u30ad\u30fc\u30dc\u30fc\u30c9\u304c\u91cd\u306a\u308b\u5834\u5408\u3001\u7de8\u96c6\u4e2d\u30bb\u30eb\u3092\u753b\u9762\u4e2d\u592e\u3078\u79fb\u52d5\u3055\u305b\u308b\r\n    \/\/ \u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u9ad8\u3055\u5206\u306e insets \u3092\u4f5c\u6210\u3059\u308b    \r\n    UIEdgeInsets insets;\r\n    insets = UIEdgeInsetsMake(0.0f, 0.0f, keyboardTop, 0.0f);\r\n    \r\n    NSTimeInterval duration;\r\n    UIViewAnimationCurve animationCurve;\r\n    void (^animations)(void);\r\n    duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];\r\n    animationCurve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];\r\n    animations = ^(void) {\r\n        self.tableView.contentInset = insets;\r\n        self.tableView.scrollIndicatorInsets = insets;\r\n    };\r\n    [UIView animateWithDuration:duration delay:0.0 options:(animationCurve << 16) animations:animations completion:nil];\r\n    \r\n    \/\/ \u7de8\u96c6\u4e2d\u30bb\u30eb\u306e\u4f4d\u7f6e\u3092\u8abf\u6574\u3059\u308b\r\n    CGRect rect = cell.frame;\r\n    rect.origin.y = cellFrame.origin.y - 300.f;\r\n    \r\n    [self.tableView scrollRectToVisible:rect animated:YES];\r\n}\r\n\r\n- (void)keybaordWillHide:(NSNotification*)notification\r\n{\r\n    NSDictionary *userInfo;\r\n    userInfo = [notification userInfo];\r\n    \r\n    NSTimeInterval duration;\r\n    UIViewAnimationCurve animationCurve;\r\n    void (^animations)(void);\r\n    duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];\r\n    animationCurve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];\r\n    animations = ^(void) {\r\n        \/\/ insets \u3092 0 \u306b\u3059\u308b\r\n        self.tableView.contentInset = UIEdgeInsetsZero;\r\n        self.tableView.scrollIndicatorInsets = UIEdgeInsetsZero;\r\n    };\r\n    [UIView animateWithDuration:duration delay:0.0 options:(animationCurve << 16) animations:animations completion:nil];  \r\n}\r\n\r\n<\/pre>\n<a href=\"https:\/\/twitter.com\/redwing1300?ref_src=twsrc%5Etfw\" class=\"twitter-follow-button\" data-size=\"large\" data-show-count=\"false\">Follow @redwing1300<\/a><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content --><div id=\"redwi-874773768\" class=\"redwi- redwi-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-9652476346722993\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-9652476346722993\" \ndata-ad-slot=\"\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u306e\u69d8\u306a\u30c6\u30fc\u30d6\u30eb \u30d3\u30e5\u30fc\u3092\u30c7\u30b6\u30a4\u30f3\u3057\u305f\u3068\u3057\u307e\u3059\u3002 \u30c6\u30fc\u30d6\u30eb\u306e\u30bb\u30eb\u306b\u306f\u30c6\u30ad\u30b9\u30c8 \u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u914d\u7f6e\u3055\u308c\u3066\u304a\u308a\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u304b\u3089\u306e\u5165\u529b\u304c\u53ef\u80fd\u3068\u3057\u307e\u3059\u3002 \u30dc\u30bf\u30f310\u306e\u30bf\u30a4\u30c8\u30eb\u884c\u306a\u3069\u306b\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u3092\u884c\u304a\u3046\u3068\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u79fb\u52d5\u3059\u308b\u3068 &hellip; <a href=\"https:\/\/redwing.moo.jp\/cocoa\/archives\/783\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4],"tags":[15,14],"class_list":["post-783","post","type-post","status-publish","format-standard","hentry","category-cocoa","category-xcode4","tag-keyboard","tag-uitableview"],"_links":{"self":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/comments?post=783"}],"version-history":[{"count":19,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"predecessor-version":[{"id":2005,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/783\/revisions\/2005"}],"wp:attachment":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}