Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longseespace/564031 to your computer and use it in GitHub Desktop.
Save longseespace/564031 to your computer and use it in GitHub Desktop.
From 279e53c3abe39970f6cf946baec95a36f99d95d2 Mon Sep 17 00:00:00 2001
From: Chih-Wei Lee <dlackty@gmail.com>
Date: Thu, 10 Jun 2010 14:39:35 -0700
Subject: [UI|UICommon] remove the 3.2 keyboard APIs due to dyld errors on older OS versions
---
src/Three20UI/Sources/UIViewAdditions.m | 38 ++++++--------------
src/Three20UICommon/Sources/TTBaseViewController.m | 30 +++++-----------
2 files changed, 20 insertions(+), 48 deletions(-)
diff --git a/src/Three20UI/Sources/UIViewAdditions.m b/src/Three20UI/Sources/UIViewAdditions.m
index 9344e11..855af3c 100644
--- a/src/Three20UI/Sources/UIViewAdditions.m
+++ b/src/Three20UI/Sources/UIViewAdditions.m
@@ -452,33 +452,17 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (NSDictionary *)userInfoForKeyboardNotification {
CGRect screenFrame = TTScreenBounds();
-#ifdef __IPHONE_3_2
- if (TTOSVersion() >= 3.2) {
- CGSize keyboardSize = CGSizeMake(screenFrame.size.width, self.height);
- CGRect frameBegin = CGRectMake(screenFrame.size.width - self.width,
- screenFrame.size.height,
- keyboardSize.width, keyboardSize.height);
- CGRect frameEnd = CGRectMake(screenFrame.size.width - self.width,
- screenFrame.size.height - self.height,
- keyboardSize.width, keyboardSize.height);
-
- return [NSDictionary dictionaryWithObjectsAndKeys:
- [NSValue valueWithCGRect:frameBegin], UIKeyboardFrameBeginUserInfoKey,
- [NSValue valueWithCGRect:frameEnd], UIKeyboardFrameEndUserInfoKey,
- nil];
- }
-#endif
- CGRect bounds = CGRectMake(0, 0, screenFrame.size.width, self.height);
- CGPoint centerBegin = CGPointMake(floor(screenFrame.size.width/2 - self.width/2),
- screenFrame.size.height + floor(self.height/2));
- CGPoint centerEnd = CGPointMake(floor(screenFrame.size.width/2 - self.width/2),
- screenFrame.size.height - floor(self.height/2));
-
- return [NSDictionary dictionaryWithObjectsAndKeys:
- [NSValue valueWithCGRect:bounds], UIKeyboardBoundsUserInfoKey,
- [NSValue valueWithCGPoint:centerBegin], UIKeyboardCenterBeginUserInfoKey,
- [NSValue valueWithCGPoint:centerEnd], UIKeyboardCenterEndUserInfoKey,
- nil];
+ CGRect bounds = CGRectMake(0, 0, screenFrame.size.width, self.height);
+ CGPoint centerBegin = CGPointMake(floor(screenFrame.size.width/2 - self.width/2),
+ screenFrame.size.height + floor(self.height/2));
+ CGPoint centerEnd = CGPointMake(floor(screenFrame.size.width/2 - self.width/2),
+ screenFrame.size.height - floor(self.height/2));
+
+ return [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSValue valueWithCGRect:bounds], UIKeyboardBoundsUserInfoKey,
+ [NSValue valueWithCGPoint:centerBegin], UIKeyboardCenterBeginUserInfoKey,
+ [NSValue valueWithCGPoint:centerEnd], UIKeyboardCenterEndUserInfoKey,
+ nil];
}
diff --git a/src/Three20UICommon/Sources/TTBaseViewController.m b/src/Three20UICommon/Sources/TTBaseViewController.m
index d5b505d..38b5cc8 100644
--- a/src/Three20UICommon/Sources/TTBaseViewController.m
+++ b/src/Three20UICommon/Sources/TTBaseViewController.m
@@ -91,28 +91,16 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)resizeForKeyboard:(NSNotification*)notification appearing:(BOOL)appearing {
-#if __IPHONE_3_2 && __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
- CGRect keyboardStart;
- [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&keyboardStart];
+ CGRect keyboardBounds;
+ [[notification.userInfo objectForKey:UIKeyboardBoundsUserInfoKey] getValue:&keyboardBounds];
- CGRect keyboardEnd;
- [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEnd];
+ CGPoint keyboardStart;
+ [[notification.userInfo objectForKey:UIKeyboardCenterBeginUserInfoKey] getValue:&keyboardStart];
- CGRect keyboardBounds = CGRectMake(0, 0, keyboardEnd.size.width, keyboardEnd.size.height);
+ CGPoint keyboardEnd;
+ [[notification.userInfo objectForKey:UIKeyboardCenterEndUserInfoKey] getValue:&keyboardEnd];
- BOOL animated = keyboardStart.origin.y != keyboardEnd.origin.y;
-#else
- CGRect keyboardBounds;
- [[notification.userInfo objectForKey:UIKeyboardBoundsUserInfoKey] getValue:&keyboardBounds];
-
- CGPoint keyboardStart;
- [[notification.userInfo objectForKey:UIKeyboardCenterBeginUserInfoKey] getValue:&keyboardStart];
-
- CGPoint keyboardEnd;
- [[notification.userInfo objectForKey:UIKeyboardCenterEndUserInfoKey] getValue:&keyboardEnd];
-
- BOOL animated = keyboardStart.y != keyboardEnd.y;
-#endif
+ BOOL animated = keyboardStart.y != keyboardEnd.y;
if (animated) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:TT_TRANSITION_DURATION];
@@ -287,7 +275,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)keyboardDidShow:(NSNotification*)notification {
-#if __IPHONE_3_2 && __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
+#ifdef __IPHONE_3_21
CGRect frameStart;
[[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&frameStart];
@@ -311,7 +299,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)keyboardWillHide:(NSNotification*)notification {
-#if __IPHONE_3_2 && __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
+#ifdef __IPHONE_3_21
CGRect frameEnd;
[[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&frameEnd];
--
1.7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment