【发布时间】:2015-08-04 05:47:41
【问题描述】:
在我的应用程序中,有一个子视图用于实现自动完成。它在单击按钮时出现。它在正常情况下工作正常。但是当我将全部内容嵌入到 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];}
【问题讨论】:
-
_viewForAuto 的父视图是什么。
-
scrollArea 是它的超级视图
-
试试这个 [_scrollArea bringSubviewToFront:_viewForAuto];而不是 [self.view bringSubviewToFront:_viewForAuto];
-
对不起,控件没有流入按钮的动作
-
现在我通过删除 [self.view addSubview:_scrollArea] 来控制流向动作部分;但你建议的修改不起作用
标签: ios uiview uiscrollview