diff --git a/Classes/BITFeedbackListViewCell.m b/Classes/BITFeedbackListViewCell.m index e10afbb82a..d5c343eb13 100644 --- a/Classes/BITFeedbackListViewCell.m +++ b/Classes/BITFeedbackListViewCell.m @@ -198,15 +198,11 @@ for (BITFeedbackMessageAttachment *attachment in attachments){ UIButton *imageView = [UIButton buttonWithType:UIButtonTypeCustom]; [imageView setImage:[attachment thumbnailWithSize:CGSizeMake(ATTACHMENT_SIZE, ATTACHMENT_SIZE)] forState:UIControlStateNormal]; - [imageView setTitle:attachment.originalFilename forState:UIControlStateNormal]; - [imageView setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; - [imageView setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter]; [imageView addTarget:self action:@selector(imageButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - imageView.contentMode = UIViewContentModeScaleAspectFill; - [self.attachmentViews addObject:imageView]; + [self addSubview:imageView]; } } diff --git a/Classes/BITImageAnnotationViewController.m b/Classes/BITImageAnnotationViewController.m index 5bf851a00a..9f8c74f6d4 100644 --- a/Classes/BITImageAnnotationViewController.m +++ b/Classes/BITImageAnnotationViewController.m @@ -103,24 +103,42 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; + [self fitImageViewFrame]; } +- (void)viewWillDisappear:(BOOL)animated { + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; + +} + - (BOOL)prefersStatusBarHidden { return self.navigationController.navigationBarHidden || self.navigationController.navigationBar.alpha == 0.0f; } +- (void)orientationDidChange:(NSNotification *)notification { + [self fitImageViewFrame]; +} + - (void)fitImageViewFrame { - CGFloat heightScaleFactor = [[UIScreen mainScreen] bounds].size.height / self.image.size.height; - CGFloat widthScaleFactor = [[UIScreen mainScreen] bounds].size.width / self.image.size.width; + + CGSize size = [UIScreen mainScreen].bounds.size; + if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)){ + size = CGSizeMake(size.height, size.width); + } + + CGFloat heightScaleFactor = size.height / self.image.size.height; + CGFloat widthScaleFactor = size.width / self.image.size.width; CGFloat factor = MIN(heightScaleFactor, widthScaleFactor); self.scaleFactor = factor; CGSize scaledImageSize = CGSizeMake(self.image.size.width * factor, self.image.size.height * factor); - CGRect baseFrame = CGRectMake(self.view.frame.size.width/2 - scaledImageSize.width/2, self.view.frame.size.height - [[UIScreen mainScreen] bounds].size.height, scaledImageSize.width, scaledImageSize.height); + CGRect baseFrame = CGRectMake(self.view.frame.size.width/2 - scaledImageSize.width/2, self.view.frame.size.height - size.height, scaledImageSize.width, scaledImageSize.height); self.imageView.frame = baseFrame; }