Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dynamically adjusting large image based on photo aspect ratio

  • Loading branch information...
commit 2aeed5071e3a010593655fa230e9b086dca6e014 1 parent a4a4099
gBit authored
Showing with 32 additions and 31 deletions.
  1. +32 −31 MappingMashupApp/FlickrMapViewController.m
View
63 MappingMashupApp/FlickrMapViewController.m
@@ -19,7 +19,6 @@
#import "Photo.h"
#import "Business.h"
#import "UIView+AnimationTools.h"
-//Paul Testing - delete if this comment is still here on 3/24
#import "ResultsManager.h"
@interface FlickrMapViewController ()
@@ -60,9 +59,7 @@ - (void)viewDidLoad
[super viewDidLoad];
isZoomedInYet = NO;
didSelectThumbnail = NO;
- //God help us, please make the location services work! Puh_LEASE JESUS
- //[self startLocationUpdates];
- //Moved this here (ross 3.25.13)
+
if(missLocationManager == nil)
{
missLocationManager = [[CLLocationManager alloc]init];
@@ -441,42 +438,46 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *
}
if (didSelectThumbnail == NO)
{
+ didSelectThumbnail = YES;
+ [view squishImage];
+
+ selectedAnnotation = view.annotation;
+ [self displayFullSizedImageForSelectedAnnotation:selectedAnnotation];
+
+ [enlargedPhotoViewOutlet lowerImageView];
+ }
+ else
+ {
+ selectedAnnotation = view.annotation;
+ [self displayFullSizedImageForSelectedAnnotation:selectedAnnotation];
- didSelectThumbnail = YES;
- [view squishImage];
-
-
- selectedAnnotation = view.annotation;
-
- //Code to make the selected image show up in the photo viewer
- NSString *photoFullSizeURLString = [selectedAnnotation.flickrThumbnailString stringByReplacingOccurrencesOfString:@"s.jpg" withString:@"n.jpg"];
+ }
+}
+
+- (void)displayFullSizedImageForSelectedAnnotation:(Annotation*)annotation
+{
+ // grab the medium sized version of the annotion image from flickr
+ NSString *photoFullSizeURLString = [annotation.flickrThumbnailString stringByReplacingOccurrencesOfString:@"s.jpg" withString:@"n.jpg"];
NSURL *photoFullSizeURL = [NSURL URLWithString:photoFullSizeURLString];
-
NSData *photoData = [NSData dataWithContentsOfURL:photoFullSizeURL];
UIImage *photoFullSize = [UIImage imageWithData:photoData];
- photoViewerUIImageView.image = photoFullSize;
-
- [enlargedPhotoViewOutlet lowerImageView];
-
+ // adjust the containing view and imageView to match the photo's aspect ratio
+ float photoWidth = photoFullSize.size.width;
+ float photoHeight = photoFullSize.size.height;
+ float photoAspectRatio = photoWidth/photoHeight;
- }
-
- else{
- selectedAnnotation = view.annotation;
+ float imageViewWidth = photoViewerUIImageView.frame.size.width;
+ float imageViewHeight = imageViewWidth/photoAspectRatio;
- //Code to make the selected image show up in the photo viewer
- NSString *photoFullSizeURLString = [selectedAnnotation.flickrThumbnailString stringByReplacingOccurrencesOfString:@"s.jpg" withString:@"n.jpg"];
- NSURL *photoFullSizeURL = [NSURL URLWithString:photoFullSizeURLString];
-
- NSData *photoData = [NSData dataWithContentsOfURL:photoFullSizeURL];
- UIImage *photoFullSize = [UIImage imageWithData:photoData];
- photoViewerUIImageView.image = photoFullSize;
-
- }
+ CGRect scaledImageView = CGRectMake(5.0f, 5.0f, imageViewWidth, imageViewHeight);
+ [photoViewerUIImageView setFrame:scaledImageView];
+ photoViewerUIImageView.image = photoFullSize;
+
+ CGRect scaledSuperView = CGRectMake(10.0f, 10.0f, imageViewWidth + 10, imageViewHeight + 10);
+ [photoViewerUIImageView.superview setFrame:scaledSuperView];
}
-
- (IBAction)fullSizedPhotoTapped:(id)sender
{
latitudeToPass = selectedAnnotation.coordinate.latitude;
Please sign in to comment.
Something went wrong with that request. Please try again.