【发布时间】:2012-10-07 14:15:49
【问题描述】:
当我在 Xcode 中创建和设置滚动视图时,它永远不会工作。它根本不会滚动并显示我的内容!我已经编码了它的后端,但不行!我从 iOS 4 开始就一直在使用这个教程:Devx Scrollview Tutorial
现在,我认为由于新 iPhone 上的新屏幕尺寸,它在 iOS 6 中被破坏了。这是我一直在使用的后端代码:
scrollView.frame = CGRectMake(0, 0, 320, 520);
//---set the content size of the scroll view---
[scrollView setContentSize:CGSizeMake(320, 520)];
// Do any additional setup after loading the view.
Xcode 中的滚动视图大小为 Width: 320, Height: 520。
我做错了什么?这可能是一些愚蠢的事情。
更新:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.overlay removeFromSuperview];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow:) name:
UIKeyboardWillShowNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillHide:) name:
UIKeyboardWillHideNotification object:nil];
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(didTapAnywhere:)];
[self customizeAppearance];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"stone.png"]];
[scrollView setScrollEnabled:YES];
scrollView.frame = ([UIScreen mainScreen].bounds);
//---set the content size of the scroll view---
[scrollView setContentSize:CGSizeMake(320, 800)];
// Do any additional setup after loading the view.
}
【问题讨论】:
-
您所期望的具体没有发生什么?
-
好的,但是滚动视图中有多少内容?如果它小于您刚刚设置的内容大小的高度,则它不会滚动。通常,您将内容大小的高度设置为最后一个对象的 y 原点加上它的高度。
-
我该怎么做呢?我向您展示了我的代码,并且滚动视图具有完全相同的值。
-
如果你想让 scollview 滚动,将其内容大小的高度设置为更高的值。 (假设里面的物体比框架高度占用更多的空间)
-
这么多,在代码中,我说它更高,滚动视图的值?
标签: ios xcode ios6 scrollview