在我看来,我创建了一个宽度为320,高度为70的滚动视图。
响应用户触摸按钮,我扩大了滚动视图,因此它的大小为380(h)x 320(w)。
代码如下所示:
CGRect scrollviewFrame = CGRectMake(0, 30, 320, 380); [scrollView setFrame:scrollviewFrame]; [self layoutScrollImages:YES]; CGSize srect = CGSizeMake([scrollView bounds].size.width, (kNumImages * kScrollObjHeight)); [scrollView setContentSize:srect];在我调试这个项目时,我可以看到这个尺寸是320(w)x 8000(h); 然而,我的问题是可滚动区域(用户可以实际触摸以滚动滚动视图)与原始大小时保持不变。
我明显错过了一些东西,有人知道它是什么吗?
编辑:我创建了一个示例项目来说明我遇到的问题,它可以在这里找到: http : //dl.dropbox.com/u/9930498/ScrollViewTest.zip
Within my view I create a scrollview with a width of 320 and a height of 70.
Responding to the user touching a button, I expand the scrollview, so it is 380(h) x 320(w) in size.
The code for this is shown below:
CGRect scrollviewFrame = CGRectMake(0, 30, 320, 380); [scrollView setFrame:scrollviewFrame]; [self layoutScrollImages:YES]; CGSize srect = CGSizeMake([scrollView bounds].size.width, (kNumImages * kScrollObjHeight)); [scrollView setContentSize:srect];As I debug this project, I can see that srect is 320 (w) x 8000 (h) in size; however my issue is the scrollable area (where the user can actually touch to scroll the scrollview) remains the same as when it was it's original size.
I'm obviously missing something, does anyone know what it is?
Edit: I have created a sample project to illustrate the issue I am having, it is available here: http://dl.dropbox.com/u/9930498/ScrollViewTest.zip
最满意答案
我想,你有问题与你的下面的代码行。
CGSize srect = CGSizeMake([scrollView bounds].size.width, (kNumImages * kScrollObjHeight)); [scrollView setContentSize:srect];调试你的程序并看清楚内容,也让我们知道下面两个常量的值
kNumImages , kScrollObjHeight 。
I think , you have issue with your below line of code.
CGSize srect = CGSizeMake([scrollView bounds].size.width, (kNumImages * kScrollObjHeight)); [scrollView setContentSize:srect];debug your program and see the content of srect , Also let us know the value of below two constant
kNumImages,kScrollObjHeight .
更多推荐
发布评论