启用 UIScrollView 时不显示子视图

Subviews not appearing when UIScrollView is enabled

在我的应用程序中,有一个子视图用于实现自动完成。单击按钮时出现。它在正常情况下工作正常。但是当我将所有内容嵌入到 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;

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

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

[_autoFillData removeAllObjects];
[_theTable reloadData];}

更新:卷轴本身不工作

更新 2:更新代码(将子视图放在前面,无法使滚动条工作)

_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 必须大于框架 size.If 你想为滚动视图滚动试试这个

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