I would like to display an image (width: 320 pixels, height: 1250 pixels) in an image view.
When I compile the application I get no scrolling at all. The view stays fixed.
What I did:
- Added an
UIScrollView
via Interface Builder to my view. - Added an
UIImageView
via Interface Builder to my view. - Verified that
UIImageView
is belowUIScrollView
in Interface Builder. - Set the size of the
UIScrollView
withViewDidLoad
.
How do I do this?
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(320, 1250);
}
Screenshots:
ImageView
:
ScrollView
:
The image view has to be a subview (so inside AND below) of the scrollview. From your description it seems they are paralell
I just have done the same task.. Try this one.....
Also set this one....
You forgot one line. Add this to your view load function:
Assuming that scrollView is a subview of view and fills it entirely you can use the following in viewDidLoad:
I had a UIScrollView that was not scrolling and this allowed it to scroll.
You could try disabling AutoLayout. In XCode 5 I tested all the above answers and I could only scroll it by disabling autolayout and activating all autosizing masks under the Size Inspector. The following code was used too:
Sometimes autoLayout checkbox is ticked in the xib. That also creates this issue in xcode 5. Which makes the UIScrollView scrolling off.