Xcode 4.5 UIScrollView

2019-08-05 05:44发布

I'd like to add a scrollview to my project.

I've added the following code in my file:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [scrollView setScrollEnabled:YES];
    [scrollView setContentSize: CGSizeMake(320, 830)];
}

This works good with xcode 4.3 und IOS 5. But know it doesn't scroll.

If I deactivate Auto Layout in the file inspector it works perfect. But the layout in for iPhone 4 with the smaller display is not correct. The layout in iPhone 5 looks good.

What should I do, when I want don't to enable Auto Layout?

1条回答
我命由我不由天
2楼-- · 2019-08-05 06:18

Move this constrains to viewDidAppear. I just explained this issue on another question (Autolayout Question).

- (void)viewDidAppear
{
.....
[scrollView setScrollEnabled:YES];
[scrollView setContentSize: CGSizeMake(320, 830)];
....
}
查看更多
登录 后发表回答