Browse files

Make the home screen banner into a UIButton so it shows it's being ta…

…pped.
  • Loading branch information...
1 parent fd95058 commit 4e606970af0117e6e38740256c57be4a97328382 @justinanderson justinanderson committed Sep 30, 2012
Showing with 13 additions and 15 deletions.
  1. +13 −15 App Delegate/MITSpringboard.m
View
28 App Delegate/MITSpringboard.m
@@ -81,24 +81,22 @@ - (void)displayBannerImage {
CGFloat bannerHeight = [[bannerInfo objectForKey:@"height"] floatValue];
if (!bannerHeight) bannerHeight = 72;
- UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
- imageView.userInteractionEnabled = NO;
- imageView.frame = CGRectMake(0, 0, bannerWidth, bannerHeight);
-
- UIControl *control = (UIControl *)[self.view viewWithTag:BANNER_CONTROL_TAG];
- if (control)
- [control removeFromSuperview];
- control = [[[UIControl alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - bannerHeight, bannerWidth, bannerHeight)] autorelease];
- control.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
- control.tag = BANNER_CONTROL_TAG;
- [control addSubview:imageView];
- [control addTarget:self action:@selector(showModuleForBanner) forControlEvents:UIControlEventTouchUpInside];
-
- [self.view addSubview:control];
+ UIButton *bannerButton = (UIButton *)[self.view viewWithTag:BANNER_CONTROL_TAG];
+ if (bannerButton) {
+ [bannerButton removeFromSuperview];
+ }
+ bannerButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ bannerButton.frame = CGRectMake(0, self.view.frame.size.height - bannerHeight, bannerWidth, bannerHeight);
+ bannerButton.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
+ bannerButton.tag = BANNER_CONTROL_TAG;
+ [bannerButton setImage:image forState:UIControlStateNormal];
+ [bannerButton addTarget:self action:@selector(showModuleForBanner) forControlEvents:UIControlEventTouchUpInside];
+
+ [self.view addSubview:bannerButton];
// will trigger a relayout of grid if the frame is different
CGRect newGridFrame = grid.frame;
- newGridFrame.size.height = self.view.frame.size.height - control.frame.size.height;
+ newGridFrame.size.height = self.view.frame.size.height - bannerButton.frame.size.height;
grid.frame = newGridFrame;
}
}

0 comments on commit 4e60697

Please sign in to comment.