Skip to content

Commit

Permalink
Initial 4" Retina support in MainView.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwood committed Jan 5, 2013
1 parent 698cb39 commit 7490eef
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 253 deletions.
1 change: 0 additions & 1 deletion Classes/MainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
- (void)redrawEvent:(NSInteger)event forceRedraw:(BOOL)forceRedraw;
- (void)redrawEvents:(BOOL)forceRedraw;
- (void)redrawEventsOnTimer:(NSTimer *)timer;
- (void)resizeEventsInScroller:(float)heightDifference;
- (void)scheduleRedrawOnDayOver;
- (void)reloadEvents;
- (void)unloadEvents;
Expand Down
47 changes: 9 additions & 38 deletions Classes/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ - (void)viewDidLoad {
} else {
self.pager.numberOfPages = 1;
self.pager.currentPage = 0;
self.controls.hidden = YES;
self.bannerIsVisible = YES;
[self hideAdBanner:YES animated:NO];
}

// Recognize left/right swipes
Expand Down Expand Up @@ -198,9 +201,6 @@ - (void)handleSwipeFrom:(UISwipeGestureRecognizer *)gestureRecognizer {
- (void)showPager {
if ([self.appDelegate.appStore hasTransactionForProduct:multipleEventsProductIdentifier]) {
[UIView beginAnimations:@"animateDisplayPager" context:NULL];
self.controls.frame = CGRectOffset(self.controls.frame, 0, -self.controls.frame.size.height);
self.scroller.frame = CGRectMake(0, 0, self.scroller.frame.size.width, self.scroller.frame.size.height - (self.controls.frame.size.height / 2));
[self resizeEventsInScroller:self.controls.frame.size.height / -2];
self.pager.superview.hidden = NO;
[UIView commitAnimations];
}
Expand Down Expand Up @@ -267,21 +267,6 @@ - (IBAction)changePage:(id)sender {
self.pagerDidScroll = YES;
}

- (void)resizeEventsInScroller:(float)heightDifference {
for (EventViewController *event in self.events) {
if ((NSNull *)event != [NSNull null]) {
event.piePlate.frame = CGRectMake(event.piePlate.frame.origin.x - (heightDifference /2),
event.piePlate.frame.origin.y,
event.piePlate.frame.size.width + heightDifference,
event.piePlate.frame.size.height);
// event.controls.frame = CGRectMake(event.controls.frame.origin.x,
// event.controls.frame.origin.y,
// event.controls.frame.size.width,
// event.controls.frame.size.height + (heightDifference /2));
}
}
}

#pragma mark -
#pragma mark Scroll view delegate

Expand Down Expand Up @@ -313,25 +298,8 @@ - (void)hideAdBanner:(BOOL)hide animated:(BOOL)animated {
if (animated) {
[UIView beginAnimations:@"animateAdBanner" context:NULL];
}
if (hide) {
// Assumes the banner view is placed at the bottom of the screen.
self.adBanner.frame = CGRectOffset(self.adBanner.frame, 0, self.adBanner.frame.size.height);
self.scroller.frame = CGRectMake(self.scroller.frame.origin.x,
self.scroller.frame.origin.y,
self.scroller.frame.size.width,
self.scroller.frame.size.height + self.adBanner.frame.size.height);
[self resizeEventsInScroller:self.adBanner.frame.size.height];
self.bannerIsVisible = NO;
} else {
// Assumes the banner view is just off the bottom of the screen.
self.adBanner.frame = CGRectOffset(self.adBanner.frame, 0, - self.adBanner.frame.size.height);
self.scroller.frame = CGRectMake(self.scroller.frame.origin.x,
self.scroller.frame.origin.y,
self.scroller.frame.size.width,
self.scroller.frame.size.height - self.adBanner.frame.size.height);
[self resizeEventsInScroller:self.adBanner.frame.size.height * -1];
self.bannerIsVisible = YES;
}
self.bannerIsVisible = !hide;
self.adBanner.hidden = hide;
if (animated) {
[UIView commitAnimations];
}
Expand All @@ -343,13 +311,16 @@ - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"Loaded ad");
if ([self.adBanner superview] && !self.bannerIsVisible) {
[self hideAdBanner:NO animated:YES];
}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (self.bannerIsVisible) {
NSLog(@"Failed to receive ad");
if ([self.adBanner superview] && self.bannerIsVisible) {
NSLog(@"Hiding banner");
[self hideAdBanner:YES animated:YES];
}
}
Expand Down
Loading

0 comments on commit 7490eef

Please sign in to comment.