将硬编码值添加到 contentSize
我一直在尝试使我的滚动视图正确适合其内容,其中包括标签、UIImageView 和 textview。文本视图的大小动态地适应不同的文本,因此我使滚动视图的内容大小与文本视图的内容大小相同:
sview.contentSize = (tview.contentSize);
按预期工作,因此我的滚动视图接近我想要的大小,但我只需要添加静态 180 像素或这是为了弥补标签和图像不改变尺寸的情况。我猜想这是一个简单的 1 或 2 行代码,但我无法弄清楚。我已经尝试过:
sview.contentSize += 180;
和
CGRect extra;
extra.size.height = 180;
sview.contentSize += extra.size;
以及其他几种组合来尝试使其工作,但我不断收到错误,例如左值需要作为赋值的左操作数,或二进制 + 的无效操作数。我确信我缺少一个简单的解决方案,感谢您的帮助。
I've been trying to make my scrollview correctly fit it's content which includes a label, UIImageView, and textview. The textview sizes dynamically to different text, so I've made the scrollview's content size the same as the textview's:
sview.contentSize = (tview.contentSize);
That worked as expected, so my scrollview is close to the size I want, but I need to just add a static 180 pixels or so to make up for the label and image, which don't change size. I would guess it's an easy 1 or 2 lines of code but I can't figure it out. I've tried:
sview.contentSize += 180;
and
CGRect extra;
extra.size.height = 180;
sview.contentSize += extra.size;
and several other combinations to try to make it work but I keep getting errors like Lvalue required as left operand of assignment, or invalid operands to binary +. I'm sure I'm missing an easy solution, thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)