UIScrollView contentSize问题(UIScrollView contentSize Issue)

编程入门 行业动态 更新时间:2024-10-23 06:27:19
UIScrollView contentSize问题(UIScrollView contentSize Issue)

在我看来,我创建了一个宽度为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 .

更多推荐

本文发布于:2023-08-06 22:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457511.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UIScrollView   contentSize   Issue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!