2

I am trying to add labels to my scroll view. I have successfully made the scrollview for both iPhone and iPad size using storyboards on Xcode 5 for iOS 7, but when I add a label it no longer scrolls.

How can I fix this?

Thanks

Edit:

ViewController.h:

IBOutlet UIScrollView *scrolling;
IBOutlet UIScrollView *scrollingIpad;

ViewConroller.m

  [scrolling setScrollEnabled:YES];
    [scrollingIpad setScrollEnabled:YES];
    [scrolling setContentSize:CGSizeMake(320, 600)];
    [scrollingIpad setContentSize:CGSizeMake(768, 2000)];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
user3053939
  • 121
  • 1
  • 1
  • 6
  • How you initialize and add this label to the scrollView? And why do you have two scrollViews? You can use one `IBOutlet` to `UIScrollView` and use different `contentSize` for iPhone and iPad. – derpoliuk Dec 01 '13 at 09:40
  • is `Autolayout` enabled for the `superView`? in which case, disable it & see if you are still facing the same issue – staticVoidMan Dec 01 '13 at 10:05
  • check my updated answer below :D – Albara Dec 01 '13 at 10:11
  • My UILabel is being added by click and drag inside of the storyboard. I will just try a table view. – user3053939 Dec 01 '13 at 21:13

2 Answers2

0

You can check the method in the UIScrollView class, named setContentSize

Should fix your issue, if not, maybe you should update your question with codes and more info. Thanks.

UPDATE:

I don't see why this isn't working. However, the best way to let the controller manages itself is to use a UITableView, then add a view to it, and a label in that view.

This way, automatically, the table view will detect the size of its content then enable the scrolling for that area.

Not the best way, but a way that I have been doing and it works fine

Albara
  • 1,306
  • 8
  • 14
0
  1. Disable Autolayout on the superView

    or...

  2. Keep Autolayout on the superView but manage your constraints appropriately

also see:
UIScrollView doesn't use autolayout constraints

Community
  • 1
  • 1
staticVoidMan
  • 19,275
  • 6
  • 69
  • 98