diff --git a/Classes/PullRefreshTableViewController.m b/Classes/PullRefreshTableViewController.m index b373376..995a65f 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,26 +39,45 @@ @implementation PullRefreshTableViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self != nil) { - 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 { + 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]; } +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { + return YES; +} + - (void)addPullToRefreshHeader { - refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)]; + 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; - 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; + refreshLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]]; refreshArrow.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 27) / 2, 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; };