How to Rotate an imageview inside a UIScrollView iOS? - ios

I have a UIScrollView which has an UIImageView in it. I need to be able to to rotate the image. rotation gestures are being intercepted by the ScrollView.
self.scrollView = [[ScrollView alloc] initWithFrame:self.bounds];
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO;
self.scrollView.delegate = self;
self.scrollView.clipsToBounds = YES;
self.scrollView.decelerationRate = 0.0;
self.scrollView.backgroundColor = [UIColor clearColor];
self.scrollView.layer.borderWidth = 2.0;
self.scrollView.layer.borderColor = [[UIColor whiteColor] CGColor];
[self addSubview:self.scrollView];
//self.imageView = [[UIImageView alloc] initWithFrame:self.scrollView.frame];
self.imageView = [[UIRotateImageView alloc] initWithFrame:frame];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.backgroundColor = [UIColor blackColor];
[self.scrollView addSubview:self.imageView];
self.scrollView.minimumZoomScale = CGRectGetWidth(self.scrollView.frame) / CGRectGetWidth(self.imageView.frame);
self.scrollView.minimumZoomScale = 1.0;
self.scrollView.maximumZoomScale = 20.0;
[self.scrollView setZoomScale:self.scrollView.minimumZoomScale];
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.imageView;
}

Related

Adding Subviews/Constraints: Trying to understand WHY my subviews are not showing up

I wanted to create a popup to let users know if they attempt to input duplicate info. So initially I had a UILabel that would pop up and disappear.
UILabel *toastView = [[UILabel alloc] init];
toastView.alpha = 0;
toastView.layer.cornerRadius = 4.0f;
toastView.layer.borderColor = [UIColor colorWithRed:200.0/255.0 green:199.0/255.0 blue:204.0/255.0 alpha:1].CGColor;
CGFloat scale = [[UIScreen mainScreen] scale];
if (scale == 2.0) {
// retina screen;
toastView.layer.borderWidth = 0.5;
} else {
// non-retina screen
toastView.layer.borderWidth = 1.0;
}
toastView.backgroundColor = [UIColor colorWithRed:63.0/255.0 green:63.0/255.0 blue:63.0/255.0 alpha:1];
toastView.textAlignment = NSTextAlignmentCenter;
[toastView setAdjustsFontSizeToFitWidth:YES];
toastView.text = #" E-Mail has already been added ";
toastView.font = [UIFont fontWithName:#"HelveticaNeue" size:toastView.font.pointSize];
toastView.textColor = [UIColor whiteColor];
[toastView setTranslatesAutoresizingMaskIntoConstraints:NO];
[toastView.layer setMasksToBounds:YES];
[self.superview.superview.superview addSubview:toastView];
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:toastView];
[toastView.bottomAnchor constraintEqualToAnchor:self.superview.superview.superview.centerYAnchor].active = YES;
[toastView.centerXAnchor constraintEqualToAnchor:self.superview.superview.superview.centerXAnchor].active = YES;
[toastView.heightAnchor constraintEqualToConstant:round(self.superview.superview.superview.frame.size.height/12)].active = YES;
[toastView.widthAnchor constraintEqualToConstant:round(self.superview.superview.superview.frame.size.width/1.5)].active = YES;
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0.95;
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0;
} completion:nil];
});
}];
This worked fine. I then wanted to add an image so I decided to move the creation of this popup to a method that takes a view and a message and produces a popup view with a UILabel and UIImageView in it. Here is the code:
+(void)toastAlert:(UIView*)view message:(NSString*)message {
UIView *toastView = [[UIView alloc] init];
UILabel *toastLabel = [[UILabel alloc] init];
UIImage *infoImage = [UIImage imageNamed:#"info_white"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:infoImage];
toastView.alpha = 0;
toastView.layer.cornerRadius = 4.0f;
toastView.layer.borderColor = [UIColor colorWithRed:200.0/255.0 green:199.0/255.0 blue:204.0/255.0 alpha:1].CGColor;
CGFloat scale = [[UIScreen mainScreen] scale];
if (scale == 2.0) {
// retina screen;
toastView.layer.borderWidth = 0.5;
} else {
// non-retina screen
toastView.layer.borderWidth = 1.0;
}
[toastLabel setTextAlignment:NSTextAlignmentCenter];
[toastLabel setAdjustsFontSizeToFitWidth:YES];
[toastLabel setText:[NSString stringWithFormat:#"%#", message]];
[toastLabel setFont:[UIFont fontWithName:#"HelveticaNeue" size:toastLabel.font.pointSize]];
[toastLabel setTextColor: [UIColor whiteColor]];
toastView.backgroundColor = [UIColor colorWithRed:63.0/255.0 green:63.0/255.0 blue:63.0/255.0 alpha:1];
[toastView setTranslatesAutoresizingMaskIntoConstraints:NO];
[toastView.layer setMasksToBounds:YES];
[view addSubview:toastView];
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:toastView];
[toastView addSubview:toastLabel];
[toastView addSubview:imageView];
[toastView.bottomAnchor constraintEqualToAnchor:view.centerYAnchor].active = YES;
[toastView.centerXAnchor constraintEqualToAnchor:view.centerXAnchor].active = YES;
[toastView.heightAnchor constraintEqualToConstant:round(view.frame.size.height/12)].active = YES;
[toastView.widthAnchor constraintEqualToConstant:round(view.frame.size.width/1.5)].active = YES;
[imageView.centerYAnchor constraintEqualToAnchor:toastView.centerYAnchor].active = YES;
[imageView.leadingAnchor constraintEqualToAnchor:toastView.leadingAnchor constant:padding].active = YES;
[imageView.heightAnchor constraintEqualToConstant:toastView.frame.size.height/2].active = YES;
[imageView.widthAnchor constraintEqualToAnchor:toastView.heightAnchor].active = YES;
[toastLabel.centerYAnchor constraintEqualToAnchor:toastView.centerYAnchor].active = YES;
[toastLabel.centerXAnchor constraintEqualToAnchor:toastView.centerXAnchor constant:imageView.frame.size.width + padding*2].active = YES;
[toastLabel.leadingAnchor constraintEqualToAnchor:imageView.trailingAnchor constant:padding].active = YES;
[toastLabel.heightAnchor constraintEqualToConstant:toastView.frame.size.height/2].active = YES;
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0.95;
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0;
} completion:nil];
});
}];
}
No matter what I do, however, I can only make the UIView show up, no text or UILabel ever shows up. When I add the UIImageView, it shows up but messes up the resizing of the whole toastView.
I am still a junior developer and am sure I missed something basic...can anyone explain to me what I did incorrectly? (not just looking for a straight answer as the explanation is worth much more)
So I think your autoresizing masks were conflicting with your constraints. That and starting with a CGRectZero. I will try to address each item so you know what went wrong. Here is working code.
-(void)alteredToastAlert:(UIView*)targetView message:(NSString*)message {
CGFloat padding = 10.0;
// i like to start with real frames buggy things happen with CGRectZero
UIView *toastView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
//turn all resizing masks off
[toastView setTranslatesAutoresizingMaskIntoConstraints:NO];
UILabel *toastLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
[toastLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
UIImage *infoImage = [UIImage imageNamed:#"info_white"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:infoImage];
[imageView setTranslatesAutoresizingMaskIntoConstraints:NO];
//has a size but intrinsic
toastView.alpha = 0;
toastView.layer.cornerRadius = 4.0f;
toastView.layer.borderColor = [UIColor colorWithRed:200.0/255.0 green:199.0/255.0 blue:204.0/255.0 alpha:1].CGColor;
CGFloat scale = [[UIScreen mainScreen] scale];
if (scale == 2.0) {
// retina screen;
toastView.layer.borderWidth = 0.5;
} else {
// non-retina screen
toastView.layer.borderWidth = 1.0;
}
[toastLabel setTextAlignment:NSTextAlignmentCenter];
[toastLabel setText:[NSString stringWithFormat:#"%#", message]];
[toastLabel setFont:[UIFont fontWithName:#"HelveticaNeue" size:22]];
[toastLabel setTextColor: [UIColor whiteColor]];
[toastLabel setMinimumScaleFactor:0.01];
toastView.backgroundColor = [UIColor colorWithRed:63.0/255.0 green:63.0/255.0 blue:63.0/255.0 alpha:1];
[toastView setTranslatesAutoresizingMaskIntoConstraints:NO];
[toastView.layer setMasksToBounds:YES];
[targetView addSubview:toastView];
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:toastView];
//adding here but everything has a frame so it is not size 0. Then apply autolayout
[toastView addSubview:toastLabel];
[toastView addSubview:imageView];
[toastView.bottomAnchor constraintEqualToAnchor:targetView.centerYAnchor].active = YES;
[toastView.centerXAnchor constraintEqualToAnchor:targetView.centerXAnchor].active = YES;
[toastView.heightAnchor constraintEqualToConstant:round(targetView.frame.size.height/12)].active = YES;
[toastView.widthAnchor constraintEqualToConstant:round(targetView.frame.size.width/1.5)].active = YES;
[imageView.centerYAnchor constraintEqualToAnchor:toastView.centerYAnchor].active = YES;
[imageView.leadingAnchor constraintEqualToAnchor:toastView.leadingAnchor constant:padding].active = YES;
[imageView.heightAnchor constraintEqualToConstant:toastView.frame.size.height/2].active = YES;
[imageView.widthAnchor constraintEqualToAnchor:toastView.heightAnchor].active = YES;
imageView.backgroundColor = [UIColor redColor];
[toastLabel.centerYAnchor constraintEqualToAnchor:toastView.centerYAnchor].active = YES;
[toastLabel.leadingAnchor constraintEqualToAnchor:imageView.trailingAnchor constant:padding].active = YES;
// have to have a trailing to keep it inside the view
[toastLabel.trailingAnchor constraintEqualToAnchor:toastView.trailingAnchor constant:padding].active = YES;
[toastLabel.heightAnchor constraintEqualToConstant:toastView.frame.size.height/2].active = YES;
toastView.alpha = 1;
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0.95;
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.3 animations:^{
toastView.alpha = 0;
} completion:^(BOOL finished){
//may need to remove from superview
}];
});
}];
}
1) You will notice I set frames to start with. I do this because I notice starting with CGRectZero does some crazy things. We will eventually let the views be governed by auto layout but to start I set the frames. The imageview will establish it's intrinsic frame.
2) Next I tell the system to not create constraints from the autoresizing masks. I do this for the toastView as will as the label and imageview.
3) I tell the label a minimum scale factor for the text and I start with a value of 22 for font size that is arbitrary. You might bump it to 50 and it will still scale down. I think because of CGRectZero your font size previously was 0 but I am not sure
4) I let your constraints do the work with the edition of maybe a trailing constraint on the label but I think that is it. You can look it over.
5) When all of this is finished don't forget to remove the toastView from it's superview or the view you are passing because even though the alpha is 0 it is still there.

UITapGestureRecognizer not working, Objective-C

I apologize for asking this question for the millionth time, I've read the other questions asking the same thing and I couldn't find the answer to my problem!
I made a UITapGestureRecognizer that is just not working, can someone take a look at my code and tell me what I'm doing wrong?
-(void) formatCellForY: (CGFloat) y{
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat cellHeight = 70;
self.cell = [[UIImageView alloc] initWithImage:[UIImage imageNamed: #"Cell"]];
[self.cell setFrame:CGRectMake(20, y, screen.size.width - 40, cellHeight)];
self.cell.backgroundColor = [UIColor grayColor];
self.cell.userInteractionEnabled = YES;
self.cell.layer.shadowColor = [UIColor blackColor].CGColor;
self.cell.layer.shadowOffset = CGSizeMake(0, 1);
self.cell.layer.shadowOpacity = 1.0;
self.cell.layer.shadowRadius = 1.0;
self.cell.layer.cornerRadius = 1.0;
self.cell.clipsToBounds = NO;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, self.cell.frame.size.width - 40, cellHeight*(.4))];
titleLabel.numberOfLines = 32;
titleLabel.text = self.program.programName;
titleLabel.textColor = [UIColor whiteColor];
titleLabel.userInteractionEnabled = YES;
[self.cell addSubview:titleLabel];
UILabel *explanationLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, titleLabel.frame.origin.y + titleLabel.frame.size.height, titleLabel.frame.size.width, cellHeight - (titleLabel.frame.origin.y+ titleLabel.frame.size.height))];
explanationLabel.text = self.program.programDescription;
explanationLabel.numberOfLines = 3;
explanationLabel.textColor = [UIColor whiteColor];
explanationLabel.font = [UIFont systemFontOfSize:10.0];
explanationLabel.userInteractionEnabled = YES;
[self.cell addSubview:explanationLabel];
self.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(goToInfoPage:)];
self.tap.numberOfTapsRequired = 1;
self.tap.numberOfTouchesRequired = 1;
self.tap.enabled = YES;
[self.cell addGestureRecognizer:self.tap];
NSLog(#"%#", self.tap);
}
Here is the code I used to add the cell to the screen.
for (CKRecord *record in records) {
SBHProgram *program = [SBHProgram programForRecord:record];
SBHCell *cell = [SBHCell cellForProgram:program andY:90*i];
i++;
[scrollView addSubview:cell.cell];
}
You have missed adding self.cell to view. You are able to see labels with texts because you have added self.cell.clipsToBounds = NO;
All you have to do is add cell to view.
[self.view addSubview:self.cell]
PLEASE ADD
self.tap.delegate = self;

iOS FadeIn/FadeOut during paging

I have an UIScrollView with views inside that I can scroll horizontally. During the scroll I would like to add a fade out on the view which is going out of the screen and a fade in on the view which is going in the screen.
Here my code :
for (int i = 0; i <textEntries.count; i++)
{
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i + 5;
frame.size.width = self.scrollView.frame.size.width - 10;
frame.size.height = self.scrollView.frame.size.height - 10;
self.scrollView.pagingEnabled = YES;
UIView *subview = [[UIView alloc] initWithFrame:frame];
if([[colorEntries objectAtIndex:i] isEqualToString:#"violet"]){
subview.backgroundColor = [UIColor colorWithRed:(147/255.0) green:(90/255.0) blue:(255/255.0) alpha:1];
} else {
subview.backgroundColor = [UIColor colorWithRed:(100/255.0) green:(166/255.0) blue:(255/255.0) alpha:1];
}
subview.layer.cornerRadius = 5;
[self.scrollView addSubview:subview];
UITextView *noteLabel = [[UITextView alloc] init];
noteLabel.frame = CGRectMake(0, 0, self.scrollView.frame.size.width - 20, self.scrollView.frame.size.height -20);
noteLabel.text = [textEntries objectAtIndex:i];
noteLabel.userInteractionEnabled = NO;
noteLabel.backgroundColor = [UIColor clearColor];
noteLabel.contentInset = UIEdgeInsetsMake(20,20,20,20);
noteLabel.font = [UIFont fontWithName:#"HelveticaNeue-Bold" size:40];
[noteLabel setTextColor:[UIColor whiteColor]];
[subview addSubview:noteLabel];
[noteLabel addObserver:self forKeyPath:#"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
}
Could you help me to build this fadeIn/FadeOut effect ?
Thanks!

Image slider pages printing issue?

I'm trying to create image slider view to view 3 pictures as slider. But every time it is creating only one picture with 3 slides. So please where would be my issue?
Should it print an image in each page slide?
- (void)imageCreater{
self.view.backgroundColor = [UIColor whiteColor];
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
CGRect svrect_ = CGRectZero;
svrect_.size.height = self.view.bounds.size.height/3*2;
svrect_.size.width = self.view.bounds.size.width/3*2;
CGPoint svcenter_ = CGPointZero;
svcenter_.x = self.view.center.x;
svcenter_.y = self.view.center.y+45;
CGSize svconsize = CGSizeZero;
svconsize.height = svrect_.size.height;
svconsize.width = svrect_.size.width * 3;
CGPoint pgconcenter_ = CGPointZero;
pgconcenter_.x = self.view.center.x;
pgconcenter_.y = svcenter_.y + (svrect_.size.height/2) + 20;
CGRect btnrect_ = CGRectZero;
btnrect_.size.width = 250;
btnrect_.size.height = 50;
CGPoint btncenter_ = CGPointZero;
btncenter_.x = self.view.center.x;
btncenter_.y = self.view.bounds.size.height-65;
_backgroundimageview = [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:_backgroundimageview];
_scrollview = [[UIScrollView alloc] initWithFrame:svrect_];
_scrollview.center = svcenter_;
_scrollview.backgroundColor = [UIColor whiteColor];
_scrollview.contentSize = svconsize;
_scrollview.pagingEnabled = true;
_scrollview.bounces = false;
_scrollview.delegate = self;
_scrollview.showsHorizontalScrollIndicator = false;
_scrollview.layer.cornerRadius = 2;
[self.view addSubview:_scrollview];
_pgcontrol = [[UIPageControl alloc] initWithFrame:CGRectZero];
_pgcontrol.pageIndicatorTintColor = [UIColor colorWithWhite:0.8 alpha:1];
_pgcontrol.currentPageIndicatorTintColor = [UIColor colorWithWhite:0.6 alpha:1];
_pgcontrol.numberOfPages = 3;
_pgcontrol.currentPage = 0;
[_pgcontrol sizeToFit];
_pgcontrol.center = pgconcenter_;
[self.view addSubview:_pgcontrol];
UIImageView*iv_ = [[UIImageView alloc] initWithFrame:svrect_];
iv_.contentMode = UIViewContentModeScaleAspectFit;
iv_.clipsToBounds = true;
iv_.image = [UIImage imageNamed:#"31902.png"];
UIImageView*iv1_ = [[UIImageView alloc] initWithFrame:svrect_];
iv1_.contentMode = UIViewContentModeScaleAspectFit;
iv1_.clipsToBounds = true;
iv1_.image = [UIImage imageNamed:#"31901.png"];
UIImageView*iv2_ = [[UIImageView alloc] initWithFrame:svrect_];
iv2_.contentMode = UIViewContentModeScaleAspectFit;
iv2_.clipsToBounds = true;
iv2_.image = [UIImage imageNamed:#"31900.png"];
[_scrollview addSubview:iv_];
[_scrollview addSubview:iv1_];
[_scrollview addSubview:iv2_];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
int page_ = (int)round(scrollView.contentOffset.x / scrollView.frame.size.width);
if (page_== inter-1) {
[_button setTitle:startText forState:UIControlStateNormal];
}else{
[_button setTitle:nextText forState:UIControlStateNormal];
}
_pgcontrol.currentPage = page_;
}
You are setting the same frame to the three imageView
Change the frame as mentioned below, you will get three image in slideView
UIImageView*iv_ = [[UIImageView alloc] initWithFrame:svrect_];
iv_.contentMode = UIViewContentModeScaleAspectFit;
iv_.clipsToBounds = true;
iv_.image = [UIImage imageNamed:#"images-1.jpg"];
svrect_.origin.x += iv_.frame.size.width;
UIImageView*iv1_ = [[UIImageView alloc] initWithFrame:svrect_];
iv1_.contentMode = UIViewContentModeScaleAspectFit;
iv1_.clipsToBounds = true;
iv1_.image = [UIImage imageNamed:#"images-2.jpg"];
svrect_.origin.x += iv1_.frame.size.width;
UIImageView*iv2_ = [[UIImageView alloc] initWithFrame:svrect_];
iv2_.contentMode = UIViewContentModeScaleAspectFit;
iv2_.clipsToBounds = true;
iv2_.image = [UIImage imageNamed:#"images-3.jpg"];
[_scrollview addSubview:iv_];
[_scrollview addSubview:iv1_];
[_scrollview addSubview:iv2_];

ScrollViews will not resize

I have struggled with this and maybe I am not understanding how scrollviews work. I am trying to calculate the height automatically for 'self.description' however nothing I do seems to work. I have changed values from the scrollviewframe even tried changing the values using frame.size.height. however it still does not calculate the height. Am i missing something?
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
if (self) {
CGRect scrollViewFrame = CGRectMake(0, 0, 460, 590);
scrollView = [[UIScrollView alloc] initWithFrame:scrollViewFrame];
[self.contentView addSubview:self.scrollView];
[scrollView setCanCancelContentTouches:NO];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = NO;
self.label = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 67.0, 290, 50)];
self.label.font= [UIFont fontWithName:#"Helvetica-Bold" size:20];
self.label.textColor = [UIColor colorWithRed:33.0f/255.0f green:74.0f/255.0f blue:146.0f/255.0f alpha:1.0f];
self.label.numberOfLines = 0;
self.label.lineBreakMode = NSLineBreakByWordWrapping;
self.label.backgroundColor = [UIColor whiteColor];
[scrollView addSubview:self.label];
//[self.contentView addSubview:self.label];
self.description = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 380.0, 300, 9999)];
self.description.font= [UIFont fontWithName:#"Helvetica-Light" size:15];
self.description.textColor = [UIColor blackColor];
self.description.textAlignment = NSTextAlignmentJustified;
self.description.numberOfLines = 0;
self.description.lineBreakMode = NSLineBreakByWordWrapping;
self.description.backgroundColor = [UIColor whiteColor];
[scrollView addSubview:self.description];
//[self.contentView addSubview:self.description];
self.image = [[UIImageView alloc] initWithFrame:CGRectMake(20, 130, 280, 228)];
self.image.clipsToBounds = YES;
[scrollView addSubview:self.image];
//[self.contentView addSubview:self.image];
float hgt=0; for (UIView *view in scrollView.subviews) hgt+=view.frame.size.height;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width,hgt)];
self.backgroundColor = [UIColor whiteColor];
}
}
Are you trying to resize scrollview or the content size of the scroll?
If you like to resize scrollview, the self.contentView aren't resized and if it is not bigger or equal to scrollview, probably it's your issue.
float contentHeight = 0;
contentHeight = yourLastSubview.frame.origin.x + yourLastSubview.frame.size.height;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width,contentHeight)];
//yourLastSubview is for example your self.description, because self.description' origin.y is the largest (380)
If your scrollView.frame.size.height is bigger than contentHeight, your scrollView won't scroll. For example if your scrollView.frame = CGRectMake(0,0,320,480); and your contentHeight is 400 scrollView won't scroll, but if contentHeight = 500; it will.
If you want to enable bouncing your scrollView when the contentHeight is smaller than your scrollView Height use this: scrollView.alwaysBounceVertical = YES;

Resources