在Xcode Storyboard编辑器中如何在UIScrollView内进行滚动

huangapple go评论66阅读模式
英文:

How to scroll inside of UIScrollView in Xcode Storyboard Editor

问题

我有一个水平滚动的UIScrollView,它在屏幕外运行。请参见图像:

在Xcode Storyboard编辑器中如何在UIScrollView内进行滚动

我想要能够更直接地在Storyboard中编辑内容,而不是猜测要放置视图等。正如你在上面的图像中所看到的,你无法看到UILabel的整个文本,也无法看到末尾的ImageView,更不用说我可能想要放置的其他任何内容了。

我正在使用Xcode 14.2。

英文:

I have a horizontally scrolling UIScrollView that runs "off" the screen. See image:

在Xcode Storyboard编辑器中如何在UIScrollView内进行滚动

I want to be able to edit the content more directly in the Storyboard rather than guessing where to put Views etc. As you see in the image above, you can't see the entire text of the UILabel, nor the ImageView at the end, much less anything else I might want to put there.

I'm using Xcode 14.2.

答案1

得分: 1

我在十年前回答过这个问题,也许在几个月后以更好的方式回答了,但由于苹果设计的无尽变化,此过程略有不同,所以这里有一个新答案。

在故事板编辑器中无法滚动滚动视图。作为一种解决方法,您可以使场景变宽,滚动视图变宽,以便在故事板编辑器中查看其所有内容。

  1. 在故事板大纲中选择视图控制器。

  2. 打开“尺寸检查器”。将“模拟大小”设置从“固定”更改为“自由形式”。

  3. 根据需要增加模拟大小的宽度,以便可以使滚动视图足够宽以查看其所有内容。根据您的约束(或自动调整掩模)的设置方式,滚动视图可能会自动变宽。

英文:

I answered this ten years ago, and in a perhaps better way a few months after, but due to the endless vicissitude of Apple's designs, the procedure has become slightly different, so here's a new answer.

You can't scroll a scroll view in the storyboard editor. As a workaround, you can make the scene wider, and the scroll view wider, so that you can see all of its content in the storyboard editor.

  1. Select the view controller in the storyboard outline.

    在Xcode Storyboard编辑器中如何在UIScrollView内进行滚动

  2. Open the Size inspector. Change the setting for “Simulated Size” from “Fixed” to “Freeform”.

    在Xcode Storyboard编辑器中如何在UIScrollView内进行滚动

  3. Increase the width of the simulated size as needed so that you can make your scroll view wide enough to see all its content. Depending on how your constraints (or autoresizing mask) are set up, the scroll view may get wider automatically.

huangapple
  • 本文由 发表于 2023年2月7日 04:05:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366047.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定