This commit is contained in:
moritz haarmann
2014-04-11 17:43:34 +02:00
parent cf17b298a7
commit b230c964a6
3 changed files with 21 additions and 11 deletions

View File

@@ -52,6 +52,9 @@
[self extractUsableAttachments];
[self setupScrollView];
self.view.frame = UIScreen.mainScreen.applicationFrame;
// self.view.frame.origin = CGPointZero;
[self layoutViews];
}
@@ -80,7 +83,7 @@
for (int i = 0; i<3; i++){
UIImageView *newImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
[imageviews addObject:newImageView];
newImageView.contentMode = UIViewContentModeScaleAspectFit;
newImageView.contentMode = UIViewContentModeScaleAspectFit|UIViewContentModeBottom;
[self.scrollView addSubview:newImageView];
}
@@ -113,11 +116,7 @@
NSInteger newIndex = self.scrollView.contentOffset.x / self.scrollView.frame.size.width;
if (newIndex!=self.currentIndex){
self.currentIndex = newIndex;
// requeue elements.
NSInteger baseIndex = MAX(0,self.currentIndex-1);
[self layoutViews];
}
}
@@ -126,6 +125,10 @@
self.scrollView.frame = self.view.bounds;
self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.view.bounds) * self.extractedAttachments.count, CGRectGetHeight(self.view.bounds));
self.scrollView.contentInset = UIEdgeInsetsZero;
self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x, 0);
NSInteger baseIndex = MAX(0,self.currentIndex-1);
NSInteger z = baseIndex;
for ( NSInteger i = baseIndex; i < MIN(baseIndex+2, self.extractedAttachments.count);i++ ){
@@ -163,10 +166,11 @@
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
[self layoutViews];
}
- (CGRect)frameForItemAtIndex:(NSInteger)index {
return CGRectMake(index * CGRectGetWidth(self.scrollView.frame), 0, CGRectGetWidth(self.scrollView.frame), CGRectGetHeight(self.scrollView.frame));
return CGRectMake(index * CGRectGetWidth(self.scrollView.frame), 0, CGRectGetWidth(self.scrollView.frame), CGRectGetHeight(self.view.bounds));
}
@end

View File

@@ -184,8 +184,7 @@
self.textAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
self.textAccessoryView.backgroundColor = [UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.0f];
UIButton *addPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addPhotoButton setTitle:@"+ Add Photo" forState:UIControlStateNormal];
[addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
[addPhotoButton setTitle:@"+ Add Photo" forState:UIControlStateNormal]; [addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
addPhotoButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44);
[addPhotoButton addTarget:self action:@selector(addPhotoAction:) forControlEvents:UIControlEventTouchUpInside];

View File

@@ -107,7 +107,7 @@
- (UIImage *)imageRepresentation {
if ([self.contentType rangeOfString:@"image"].location != NSNotFound){
return [UIImage imageWithData:self.data];
return [UIImage imageWithData:self.data scale:[UIScreen mainScreen].scale];
} else {
return bit_imageNamed(@"feedbackActiviy.png", BITHOCKEYSDK_BUNDLE); // TODO add another placeholder.
}
@@ -118,9 +118,16 @@
if (!self.thumbnailRepresentations[cacheKey]){
UIImage *image = self.imageRepresentation;
UIImage *thumbnail = bit_imageToFitSize(image, size, NO);
// consider the scale.
CGFloat scale = [UIScreen mainScreen].scale;
CGSize scaledSize = CGSizeApplyAffineTransform(size, CGAffineTransformMakeScale(scale, scale));
UIImage *thumbnail = bit_imageToFitSize(image, scaledSize, NO) ;
UIImage *scaledTumbnail = [UIImage imageWithCGImage:thumbnail.CGImage scale:scale orientation:thumbnail.imageOrientation];
if (thumbnail){
[self.thumbnailRepresentations setObject:thumbnail forKey:cacheKey];
[self.thumbnailRepresentations setObject:scaledTumbnail forKey:cacheKey];
}
}