diff --git a/Classes/BITFeedbackListViewCell.m b/Classes/BITFeedbackListViewCell.m index 912a377042..c0526376cd 100644 --- a/Classes/BITFeedbackListViewCell.m +++ b/Classes/BITFeedbackListViewCell.m @@ -210,7 +210,7 @@ [imageView addTarget:self action:@selector(imageButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self.attachmentViews addObject:imageView]; - [self addSubview:imageView]; + //[self addSubview:imageView]; } @@ -289,7 +289,7 @@ for ( BITActivityIndicatorButton *imageButton in self.attachmentViews){ imageButton.contentMode = UIViewContentModeScaleAspectFit; imageButton.imageView.contentMode = UIViewContentModeScaleAspectFill; - + if ( !_message.userMessage){ imageButton.frame = CGRectMake(FRAME_SIDE_BORDER + (FRAME_SIDE_BORDER + ATTACHMENT_SIZE) * (i%(int)attachmentsPerRow) , floor(i/attachmentsPerRow)*(FRAME_SIDE_BORDER + ATTACHMENT_SIZE) + baseOffsetOfText , ATTACHMENT_SIZE, ATTACHMENT_SIZE); } else { @@ -297,7 +297,11 @@ } if (!imageButton.superview){ - [self addSubview:imageButton]; + if (self.accessoryBackgroundView.superview){ + [self insertSubview:imageButton aboveSubview:self.accessoryBackgroundView]; + } else { + [self addSubview:imageButton]; + } } i++; diff --git a/Classes/BITFeedbackListViewController.m b/Classes/BITFeedbackListViewController.m index a384bc0b2d..c7595fa7e8 100644 --- a/Classes/BITFeedbackListViewController.m +++ b/Classes/BITFeedbackListViewController.m @@ -637,7 +637,7 @@ cell.labelText.delegate = self; cell.labelText.userInteractionEnabled = YES; cell.delegate = self; - [cell setAttachments:message.attachments]; + [cell setAttachments:message.previewableAttachments]; for (BITFeedbackMessageAttachment *attachment in message.attachments){ if (attachment.needsLoadingFromURL && !attachment.isLoading){ @@ -812,12 +812,7 @@ for (int i = 0; i) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index { if (index>=0){ + __weak QLPreviewController* blockController = controller; BITFeedbackMessageAttachment *attachment = self.cachedPreviewItems[index]; if (attachment.needsLoadingFromURL && !attachment.isLoading){ attachment.isLoading = YES; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:attachment.sourceURL]]; [NSURLConnection sendAsynchronousRequest:request queue:self.thumbnailQueue completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *err) { + attachment.isLoading = NO; if (responseData.length){ [attachment replaceData:responseData]; - [controller reloadData]; - [[BITHockeyManager sharedHockeyManager].feedbackManager saveMessages]; + [blockController reloadData]; + + [[BITHockeyManager sharedHockeyManager].feedbackManager saveMessages]; + } else { + [blockController reloadData]; } }]; return attachment; diff --git a/Classes/BITFeedbackMessage.h b/Classes/BITFeedbackMessage.h index 44ff0e0d7e..4587449d17 100644 --- a/Classes/BITFeedbackMessage.h +++ b/Classes/BITFeedbackMessage.h @@ -83,5 +83,11 @@ typedef NS_ENUM(NSInteger, BITFeedbackMessageStatus) { -(void)addAttachmentsObject:(BITFeedbackMessageAttachment *)object; +/** + * Returns an array of attachment objects that may be previewed on this device. + */ +- (NSArray *)previewableAttachments; + + @end diff --git a/Classes/BITFeedbackMessage.m b/Classes/BITFeedbackMessage.m index 6d2ab49c11..42da4e602f 100644 --- a/Classes/BITFeedbackMessage.m +++ b/Classes/BITFeedbackMessage.m @@ -90,6 +90,19 @@ [attachment deleteContents]; } } + +- (NSArray *)previewableAttachments { + NSMutableArray *returnArray = [NSMutableArray new]; + + for (BITFeedbackMessageAttachment *attachment in self.attachments){ + if ([QLPreviewController canPreviewItem:attachment ]){ + [returnArray addObject:attachment]; + } + } + + return returnArray; +} + -(void)addAttachmentsObject:(BITFeedbackMessageAttachment *)object{ if (!self.attachments){ self.attachments = [NSArray array];