iPhone:可以渲染不同的视图吗?

发布于 2024-08-20 00:13:16 字数 285 浏览 9 评论 0原文

我有一个问题,我无法正确解决。

简而言之:我想从多个子视图中创建一个视图(例如:UIImageView) - 即它由多个 ImageView 和 TextView 组成。问题是,我想将它们“渲染”为单个视图。

比如说,我拍摄一张图像,在下面添加一些描述,在上面添加一个标题,也许在底部添加另一个小图像。我希望这整个事情成为一个单一的 UIImage ,使它有点“听”一个(例如)滑动手势,我无法告诉它来显示新图像。

有谁知道实现这一目标的最佳方法?到目前为止,我的成绩相当差。

欢迎任何提示!

I have a problem, I can't solve properly.

In short: I want to create a single view (say: UIImageView) out of multiple subviews - i.e. it consists out of multiple ImageViews and TextViews. The thing is, I want to sort of 'render' them to be a single View.

Say, I take an image, add some description below, add a title above, and maybe another little image at the bottom. I want this whole thing to be a single UIImage to make it sort of 'listen' to one (e.g.) swiping gesture, which I cant tell to bring the new image to display.

Does anyone know the best way to achieve this? So far my results were fairly poor.

Any hints are welcome!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我是男神闪亮亮 2024-08-27 00:13:16

这绝对是可能的。您似乎了解视图和子视图,但还应该阅读“UIResponder”类和“响应程序链”。不过,您想要包含所有内容的主视图不会是 UIImageView,因为它的存在只是为了显示图像。您可以将所有您谈论的子视图(addSubview:或在 Interface Builder 中)制作为您自己子类化的普通 UIView(例如 MyContainerView),然后由它自己处理手势。如果您想利用滑动时的自由滚动,您可以将容器视图放入 UIScrollView 中,它有自己的一组可以利用的语义。对于后者,您应该查看 Apple 的滚动视图示例代码(手边没有链接,但应该很容易找到),它在滚动视图中嵌入了多个图像视图。

This is definitely possible. You seem to know about views and subviews, but should also read up on the "UIResponder" class and the "responder chain". The master view that you want to contain them all won't be a UIImageView, though, because that exists to just show an image. You can make all the ones you talk about subviews (addSubview: or in Interface Builder) of a plain UIView that you subclass yourself (say, MyContainerView), which then itself handles the gestures. If you want to take advantage of free scrolling on swipe, you could instead put your container view into a UIScrollView, which has its own set of semantics that you can leverage. For this latter, you should check out Apple's sample code for scroll views (don't have a link handy but should be easy to find) which embeds multiple image views in a scroll view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文