From: Hirami Date: Sat, 31 Mar 2012 02:24:11 +0000 (+0900) Subject: Improve detail view window size control. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=808f125bd7317dfcde1778a8eb53ccd3cd9cba97;p=tombo%2FTombo.git Improve detail view window size control. FIX: On iPad landscape mode, resize is not work correctly. FIX: When keyboard is changed, resize is not work correctly. --- diff --git a/iOS/Tombo/Tombo/DetailViewController.m b/iOS/Tombo/Tombo/DetailViewController.m index 78c5c6b..51d4b03 100644 --- a/iOS/Tombo/Tombo/DetailViewController.m +++ b/iOS/Tombo/Tombo/DetailViewController.m @@ -115,17 +115,28 @@ - (void)keyboardDidShow:(NSNotification*)notification { NSDictionary *info = [notification userInfo]; - CGRect rect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; + CGRect beginRect = [self.detailText convertRect:[[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil]; + CGRect rect = [self.detailText convertRect:[[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; CGRect frame = self.detailText.frame; - frame.size.height -= rect.size.height; + + if (beginRect.size.height == rect.size.height) { + // slide in + frame.size.height -= rect.size.height; + } else { + // keyboard change + frame.size.height -= (rect.size.height - beginRect.size.height); + } self.detailText.frame = frame; + } - (void)keyboardDidHide:(NSNotification*)notification { + NSDictionary *info = [notification userInfo]; - CGRect rect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGRect rect = [self.detailText convertRect:[[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; CGRect frame = self.detailText.frame; + frame.size.height += rect.size.height; self.detailText.frame = frame; }