Ladessa
Ladessa

Reputation: 1003

UIScrollView doesn't scroll. What's wrong?

I have created a scroll(width 320, height 420) in 'Interface Builder'.

and in class:

 -(void)viewWillAppear:(BOOL)animated {
    [scroll setContentSize:CGSizeMake(scroll.frame.size.width, 1000)];
 }

but the scroll view is not scrolling?

See the print screens

   http://imageshack.us/photo/my-images/832/scrollo.png 
  http://imageshack.us/photo/my-images/203/capturadetela20121103s2.png 
  http://img802.imageshack.us/img802/889/capturadetela20121103s2.png

Upvotes: 0

Views: 200

Answers (3)

Ladessa
Ladessa

Reputation: 1003

Problem resolved: "Auto layout" was on ... must to be off.

Upvotes: 0

sunkehappy
sunkehappy

Reputation: 9101

I think maybe you have not successfully added the images or have not successfully set the scrollView's contentSize. And I suggest you to set the contentSize after you add the image view to your scrollView. viewDidLoad is good idea. Most of the time don't do much work in viewWillAppear. The view will not be shown until this method finish.

Upvotes: 1

edzio27
edzio27

Reputation: 4140

Check if you init with your scrollView with frame:

self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 280, 360)];

Remember also to set contentSize bigger than frame, for example:

self.scrollView.contentSize = CGSizeMake(2*280, 360);

Also add delegate in your interface:

<UIScrollViewDelegate>

And delegate it:

self.scrollView.delegate = self;

Upvotes: 0

Related Questions