fab*_*ian 7 iphone uiscrollview
我想在UIScrollView中滚动我的内容.但我认为我犯了一个错误.
// setup view
CGRect appFrame = [UIScreen mainScreen].applicationFrame;
CGRect frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height);
self.view = [[[UIView alloc] initWithFrame:frame] autorelease];
// setup wrapper
UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, appFrame.size.width, appFrame.size.height + 320)];
wrapper.backgroundColor = [UIColor redColor];
wrapper.scrollEnabled = YES;
[self.view addSubview:wrapper];
// title (simple version here)
title.text = "Hello World";
[wrapper addSubview:title];
Run Code Online (Sandbox Code Playgroud)
您必须设置UIScrollView的内容大小,而不是设置大框架:
UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame:
CGRectMake(0, 0, appFrame.size.width, appFrame.size.height)];
wrapper.contentSize =CGSizeMake(appFrame.size.width, appFrame.size.height + 320);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5505 次 |
| 最近记录: |