gpt4 book ai didi

ios ScrollView 问题

转载 作者:行者123 更新时间:2023-11-29 04:41:24 24 4
gpt4 key购买 nike

我有一个 ScrollView ,它成功填充了 View ,但它没有滚动,任何人都可以看出为什么吗?

   CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];

UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];

[scrollView setContentSize:self.view.frame.size];

if (sqlite3_open(dbpath, &xxx) == SQLITE_OK)
{
// code that works
if (sqlite3_prepare_v2(xxx, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
while (sqlite3_step(statement) == SQLITE_ROW)
{
//more code that works
//add image view to view
[scrollView addSubview:myImageView];

i = i + 1;
}
sqlite3_finalize(statement);
}
sqlite3_close(xxx);
}

self.view=scrollView;

最佳答案

为了使 ScrollView 可滚动,您需要将其 contentSize 属性设置为能够包含所有内容(因此很可能大于 ScrollView 框架)。例如,如果您想水平 ScrollView ,则需要将 contentSize 宽度设置为 ImageView 数量的倍数:

...
// Loaded data and created subviews
// Now set contentSize
[scrollView setContentSize:CGSizeMake(imageWidth*numberOfImages, self.view.frame.size.height)];

关于ios ScrollView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10347671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com