gpt4 book ai didi

iphone - UIScrollView:滚动不起作用

转载 作者:行者123 更新时间:2023-12-03 18:39:28 25 4
gpt4 key购买 nike

我想在 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];

最佳答案

您必须设置 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);

关于iphone - UIScrollView:滚动不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2272627/

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