gpt4 book ai didi

ios - 启用 UIScrollView 时 subview 不会出现

转载 作者:行者123 更新时间:2023-11-29 01:46:57 27 4
gpt4 key购买 nike

在我的应用程序中,有一个 subview 用于实现自动完成。单击按钮时出现。它在正常情况下工作正常。但是当我将所有内容嵌入到 UIScrollView 中时,它不起作用。这是我的代码

_scrollArea=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1000)];
_scrollArea.contentSize=CGSizeMake(320, 1000);
_scrollArea.scrollEnabled=YES;
_scrollArea.userInteractionEnabled=YES;
[self.view addSubview:_scrollArea];
_viewForAuto.hidden=false;

现在这里是按钮点击的 Action 调用

- (IBAction)buttonOnFromPlace:(id)sender {
_selectedSlot=1;
_viewForAuto.hidden=false;
[self.view bringSubviewToFront:_viewForAuto];

[_autoFillData removeAllObjects];
[_theTable reloadData];}

更新:卷轴本身不工作

更新 2:更新代码(将 subview 放在前面,无法让滚动条工作)

_scrollArea.contentSize=CGSizeMake(320, 700);
_scrollArea.scrollEnabled=YES;

行动号召

- (IBAction)buttonOnFromPlace:(id)sender {
_selectedSlot=1;
_viewForAuto.hidden=false;
[_scrollArea bringSubviewToFront:_viewForAuto];

[_autoFillData removeAllObjects];
[_theTable reloadData];}

最佳答案

如果我们想要为 UIScrolllView 滚动,我们的 contentSize 必须大于框架大小。如果你想为你的 ScrollView 滚动,试试这个

_scrollArea.contentSize = CGSizeMake(_scrollArea.frame.size.width,2*_scrollArea.frame.size.height);

关于ios - 启用 UIScrollView 时 subview 不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31801552/

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