多次重复自定义视图

发布于 2024-11-27 01:00:48 字数 542 浏览 0 评论 0原文

我真的几乎不知道如何开始这样做,所以我只是解释一下。我有一个自定义视图,其中包含另一个较小的视图。这两个视图完全是在 IB 中构建的,主视图有几个输入字段,并且只会调整大小(我认为我已经把它缩小了很多)。第二个选项在主选项中的输入设置后出现。需要明确的是,第一个视图仅要求一些输入,一旦获得这些输入,第二个视图就会出现并开始使用这些输入值。我想做的是能够先输入一些输入,然后出现第二个视图,然后输入一些其他输入,并有另一个视图(看起来与第一个视图相同) )出现,但改为使用新的输入值。

我想知道的是,我是否必须在 IB 中多次创建相同的自定义视图,或者(我认为可能如何完成)使第二个视图成为一个单独的类,并为每个新创建一个新对象输入并从另一个类控制它们在主视图中的位置。如果这是完成的方式,我需要一些帮助,因为我真的不知道如何以编程方式创建一个新对象,或执行任何这些操作。程序必须了解视图是完全独立的,并且每个命令(例如取消)仅应用于其中一个视图。

我意识到这是非常广泛的,但我对这个特定问题没有任何经验。我基本上有一个需要一些输入的自定义视图,并且希望视图在每次发送输入时重复自身,但每个视图都彼此独立。

感谢您的帮助。

I really have almost no idea how I can even begin to do this so I'll just explain it. I have a custom view that holds another, smaller view. Those two views are entirely built in IB, the main one has several input fields and will only resize (which I think I've got pretty much down). The second one appears after the input in the main one has been set. To be clear, the first one only asks for some inputs, once is has them, the second view appears and starts using those input values. What I would like to do is to be able to put some inputs first, and have the second view appear, then put in some other inputs, and have another view (that looks the same as the first one) appear, but instead use the new input values.

What I want to know is if I have to make the same custom view in IB several times, or (how I think it might be done) to make the second view sort of a separate class, and have a new object created for each new input and, from another class, control how they're positioned in the main view. If that is the way it's done I'd like some help because I really do not know how to programmatically make a new object, or do any of these things. The program would have to understand that the views are entirely separate, and for each command (such as cancel) to be applied to only one of the views.

I realize this is very broad but I don't have any experience at all with this particular problem. I basically have a custom view that takes some input, and would like for the view to repeat itself each time inputs are sent, but for each view to be independent of one another.

Thanks for the help.

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

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

发布评论

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

评论(1

甩你一脸翔 2024-12-04 01:00:48

您可以多次加载接口文件。为此,您可以直接使用 UINibUIViewControllerNSBundle 等方法。当您实例化它时,它可能有助于设置笔尖的所有者 - 该对象将可以通过笔尖中的“文件所有者”进行连接访问。另请记住,您可以重新配置同一视图并多次使用它。有了更多信息,我们也许能够提供一些更有帮助的建议。

You can load interface files more than once. To do this you can use UINib directly, UIViewController, or NSBundle, to name a few methods. It may help to set the nib's owner when you instantiate it — this object will be accessible for connections via "File's Owner" in the nib. Also keep in mind that you could reconfigure the same view and use it more than once. With some more information we might be able to provide some more helpful suggestions.

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