Schrodingrrr
Schrodingrrr

Reputation: 4271

UIScrollView not scrolling horizontally despite setting contentSize

I have a simple app with multiple UITableViews, all of whom redirect to a single ViewController, with 2 items: a Label, and an ImageView embedded into a scrollview.

The problem is, the image, even though resized to exceed the screen size, does not scroll horizontally. It only scrolls vertically.

GammaViewController.h :

IBOutlet UIScrollView *testScroll;

GammaViewController.m :

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"Gamma View";
finalLabel.text= _selectedData;

[testScroll setScrollEnabled:YES];
[testScroll setContentSize:CGSizeMake(600,800)];
}

The ImageView has been assigned an image from the Attributes inspector, and has been resized to the scrollview contentSize i.e. (600,800).

Upvotes: 0

Views: 1678

Answers (1)

Nirav Gadhiya
Nirav Gadhiya

Reputation: 6342

May be a silly mistake that content size and frame may be same.

Try this

[testScroll setFrame:CGRectMake(0,0,320,400)];

[testScroll setContentSize:CGSizeMake(600,800)];

May this code help you.

Upvotes: 4

Related Questions