ios - 目标 C:如何在隐藏 UIView 之前使 UIScrollView 结束?
问题描述
我希望能够使 UIScrollView 在隐藏元素(UIView)之前结束。我无法从场景中删除 modeView,因为该功能当前被禁用,但将来可能会启用,一旦必须启用该功能,就必须显示 UIView (modeView)。
当 UIVIew *modeView 被隐藏时,我尝试了以下方法来降低高度,但是 UIScrollView 仍然没有在正确的位置结束。
以下是代码:
modeView.hidden = YES;
int contentViewHeight = 1000;
NSLog(@"modeView Height: %f", modeView.frame.size.height);
if(modeView.hidden == YES) {
contentViewHeight = contentViewHeight - modeView.frame.size.height;
}
else {
contentViewHeight = 1000;
}
contentView.frame = CGRectMake(0, 0, [Helper getScreenWidth], contentViewHeight);
[scrollView addSubview:contentView];
scrollView.contentSize = CGSizeMake([Helper getScreenWidth], contentViewHeight);
任何帮助将非常感激!谢谢!
解决方案
您不会根据条件更改 scrollView 高度。它需要更新。
也添加这一行:
scrollView.frame = CGRectMake([Helper getScreenWidth], contentViewHeight);
推荐阅读
- regex - Notepad++ 正则表达式:如何防止 notepad++ 在搜索中嵌入不需要的字符?
- php - 是否可以在没有作曲家的情况下使用 php 电子表格?
- javascript - 从 useRef() 获取输入值时获取 useState 是滞后的
- php - PHP-FPM 与 PHP 中的不同语言环境
- python - 为什么在子级上使用打印时调用父类的__str__函数
- scala - 使用 Scala Spark 在不同组中计算复杂统计数据的困难
- java - 使用 spring boot / thymyleaf 重定向到 HTML 页面
- go - 是自定义命名类型的转换函数还是语言构造
- android - 启动阻塞 GC Alloc / 等待阻塞 GC Alloc
- reactjs - React 功能组件,如何通过 onChange 事件动态地将属性传递给输入元素