From 91a62cf306020678f513a1cf1b962a1a46b3a3cd Mon Sep 17 00:00:00 2001 From: EverythingSolution Date: Mon, 6 Sep 2010 14:45:18 -0400 Subject: [PATCH 1/3] iPad and Rotation Additions --- Classes/PullRefreshTableViewController.h | 1 + Classes/PullRefreshTableViewController.m | 10 +++++++--- PullToRefresh.xcodeproj/project.pbxproj | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Classes/PullRefreshTableViewController.h b/Classes/PullRefreshTableViewController.h index 00450a2..d812f30 100644 --- a/Classes/PullRefreshTableViewController.h +++ b/Classes/PullRefreshTableViewController.h @@ -40,6 +40,7 @@ NSString *textPull; NSString *textRelease; NSString *textLoading; + CGFloat width; } @property (nonatomic, retain) UIView *refreshHeaderView; diff --git a/Classes/PullRefreshTableViewController.m b/Classes/PullRefreshTableViewController.m index b373376..3060445 100644 --- a/Classes/PullRefreshTableViewController.m +++ b/Classes/PullRefreshTableViewController.m @@ -32,7 +32,6 @@ #define REFRESH_HEADER_HEIGHT 52.0f - @implementation PullRefreshTableViewController @synthesize textPull, textRelease, textLoading, refreshHeaderView, refreshLabel, refreshArrow, refreshSpinner; @@ -40,6 +39,7 @@ @implementation PullRefreshTableViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self != nil) { + width = [[UIScreen mainScreen] bounds].size.width; textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; textLoading = [[NSString alloc] initWithString:@"Loading..."]; @@ -52,11 +52,15 @@ - (void)viewDidLoad { [self addPullToRefreshHeader]; } +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { + return YES; +} + - (void)addPullToRefreshHeader { - refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)]; + refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, width, REFRESH_HEADER_HEIGHT)]; refreshHeaderView.backgroundColor = [UIColor clearColor]; - refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, REFRESH_HEADER_HEIGHT)]; + refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, REFRESH_HEADER_HEIGHT)]; refreshLabel.backgroundColor = [UIColor clearColor]; refreshLabel.font = [UIFont boldSystemFontOfSize:12.0]; refreshLabel.textAlignment = UITextAlignmentCenter; diff --git a/PullToRefresh.xcodeproj/project.pbxproj b/PullToRefresh.xcodeproj/project.pbxproj index 1b23836..3f702c7 100755 --- a/PullToRefresh.xcodeproj/project.pbxproj +++ b/PullToRefresh.xcodeproj/project.pbxproj @@ -143,6 +143,7 @@ isa = PBXProject; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PullToRefresh" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -222,8 +223,10 @@ GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.2; PREBINDING = NO; - SDKROOT = iphoneos4.0; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -235,9 +238,11 @@ GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.2; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PREBINDING = NO; - SDKROOT = iphoneos4.0; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; From b19a1f809304ff550e3050bf4afce9132cd11aef Mon Sep 17 00:00:00 2001 From: EverythingSolution Date: Mon, 6 Sep 2010 15:19:05 -0400 Subject: [PATCH 2/3] Added initWithCoder setup and autoresizingmasks --- Classes/PullRefreshTableViewController.m | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Classes/PullRefreshTableViewController.m b/Classes/PullRefreshTableViewController.m index 3060445..5db4064 100644 --- a/Classes/PullRefreshTableViewController.m +++ b/Classes/PullRefreshTableViewController.m @@ -39,14 +39,26 @@ @implementation PullRefreshTableViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self != nil) { - width = [[UIScreen mainScreen] bounds].size.width; - textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; - textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; - textLoading = [[NSString alloc] initWithString:@"Loading..."]; + [self performSelector:@selector(setup)]; } return self; } +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:(NSCoder *)aDecoder]; + if (self != nil) { + [self performSelector:@selector(setup)]; + } + return self; +} + +- (void)setup { + width = [[UIScreen mainScreen] bounds].size.width; + textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; + textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; + textLoading = [[NSString alloc] initWithString:@"Loading..."]; +} + - (void)viewDidLoad { [super viewDidLoad]; [self addPullToRefreshHeader]; @@ -59,11 +71,13 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa - (void)addPullToRefreshHeader { refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, width, REFRESH_HEADER_HEIGHT)]; refreshHeaderView.backgroundColor = [UIColor clearColor]; + refreshHeaderView.autoresizingMask = UIViewAutoresizingFlexibleWidth; refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, REFRESH_HEADER_HEIGHT)]; refreshLabel.backgroundColor = [UIColor clearColor]; refreshLabel.font = [UIFont boldSystemFontOfSize:12.0]; refreshLabel.textAlignment = UITextAlignmentCenter; + refreshLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]]; refreshArrow.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 27) / 2, From 406247afbdacf8760b5fc2ff907abc81f8c6a211 Mon Sep 17 00:00:00 2001 From: EverythingSolution Date: Mon, 6 Sep 2010 20:07:29 -0400 Subject: [PATCH 3/3] got rid of width iVar --- Classes/PullRefreshTableViewController.h | 1 - Classes/PullRefreshTableViewController.m | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/PullRefreshTableViewController.h b/Classes/PullRefreshTableViewController.h index d812f30..00450a2 100644 --- a/Classes/PullRefreshTableViewController.h +++ b/Classes/PullRefreshTableViewController.h @@ -40,7 +40,6 @@ NSString *textPull; NSString *textRelease; NSString *textLoading; - CGFloat width; } @property (nonatomic, retain) UIView *refreshHeaderView; diff --git a/Classes/PullRefreshTableViewController.m b/Classes/PullRefreshTableViewController.m index 5db4064..995a65f 100644 --- a/Classes/PullRefreshTableViewController.m +++ b/Classes/PullRefreshTableViewController.m @@ -53,7 +53,6 @@ - (id)initWithCoder:(NSCoder *)aDecoder { } - (void)setup { - width = [[UIScreen mainScreen] bounds].size.width; textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; textLoading = [[NSString alloc] initWithString:@"Loading..."]; @@ -69,6 +68,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa } - (void)addPullToRefreshHeader { + CGFloat width = [[UIScreen mainScreen] bounds].size.width; refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, width, REFRESH_HEADER_HEIGHT)]; refreshHeaderView.backgroundColor = [UIColor clearColor]; refreshHeaderView.autoresizingMask = UIViewAutoresizingFlexibleWidth;