Skip to content
Browse files

Fixed scroll indicator insets issue (thanks Isaac Lim); added ARC sup…

…port; tweaked sample slightly
  • Loading branch information...
1 parent aae140e commit a3a1ac8e57aa9974af45e1de190f7363d10e06a0 @michaeltyson committed Jun 10, 2012
View
11 TPKeyboardAvoidingSample/FirstViewController.h
@@ -10,20 +10,11 @@
@class TPKeyboardAvoidingScrollView;
-@interface FirstViewController : UIViewController <UITextFieldDelegate> {
-
- TPKeyboardAvoidingScrollView *scrollView;
- UITextField *txtIggle;
- UITextField *txtNiggle;
- UITextField *txtOggle;
- UITextField *txtBogle;
- UITextField *txtSplat;
-}
+@interface FirstViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic, retain) IBOutlet TPKeyboardAvoidingScrollView *scrollView;
@property (nonatomic, retain) IBOutlet UITextField *txtIggle;
@property (nonatomic, retain) IBOutlet UITextField *txtNiggle;
@property (nonatomic, retain) IBOutlet UITextField *txtOggle;
@property (nonatomic, retain) IBOutlet UITextField *txtBogle;
@property (nonatomic, retain) IBOutlet UITextField *txtSplat;
-
@end
View
5 TPKeyboardAvoidingSample/SecondViewController.h
@@ -9,8 +9,5 @@
#import <UIKit/UIKit.h>
-@interface SecondViewController : UITableViewController <UITextFieldDelegate> {
-
-}
-
+@interface SecondViewController : UITableViewController <UITextFieldDelegate>
@end
View
2 TPKeyboardAvoidingSample/SecondViewController.m
@@ -87,7 +87,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
- return 7;
+ return 15;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
View
4 TPKeyboardAvoidingScrollView.m
@@ -39,7 +39,9 @@ -(void)awakeFromNib {
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
+#if !__has_feature(objc_arc)
[super dealloc];
+#endif
}
-(void)setFrame:(CGRect)frame {
@@ -96,6 +98,7 @@ - (void)keyboardWillShow:(NSNotification*)notification {
[self setContentOffset:CGPointMake(self.contentOffset.x,
[self idealOffsetForView:firstResponder withSpace:[self keyboardRect].origin.y - self.bounds.origin.y])
animated:YES];
+ [self setScrollIndicatorInsets:self.contentInset];
[UIView commitAnimations];
}
@@ -109,6 +112,7 @@ - (void)keyboardWillHide:(NSNotification*)notification {
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
self.contentInset = _priorInset;
+ [self setScrollIndicatorInsets:self.contentInset];
_priorInsetSaved = NO;
[UIView commitAnimations];
}
View
4 TPKeyboardAvoidingTableView.m
@@ -37,7 +37,9 @@ -(id)initWithCoder:(NSCoder *)aDecoder {
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
+#if !__has_feature(objc_arc)
[super dealloc];
+#endif
}
-(void)setFrame:(CGRect)frame {
@@ -83,6 +85,7 @@ - (void)keyboardWillShow:(NSNotification*)notification {
[self setContentOffset:CGPointMake(self.contentOffset.x,
[self idealOffsetForView:firstResponder withSpace:[self keyboardRect].origin.y - self.bounds.origin.y])
animated:YES];
+ [self setScrollIndicatorInsets:self.contentInset];
[UIView commitAnimations];
}
@@ -96,6 +99,7 @@ - (void)keyboardWillHide:(NSNotification*)notification {
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
self.contentInset = _priorInset;
+ [self setScrollIndicatorInsets:self.contentInset];
_priorInsetSaved = NO;
[UIView commitAnimations];
}

0 comments on commit a3a1ac8

Please sign in to comment.
Something went wrong with that request. Please try again.