在 UIScrollView 中生成/定位项目(iPhone Dev)
嘿,我在应用程序的主视图中有一个 UIScrollView,我想知道在其中放置一组标签和按钮的最佳方法是什么。当我开始时,只有几个,所以我可以将它们物理地放置在界面生成器中,但现在我有更多的项目要添加到 ScrollView 中,并且无法将它们全部放入界面生成器的屏幕上。有没有办法生成一系列按钮和标签?我只需要它们在一个有组织的列表中,但我不知道如何在滚动视图中生成内容,而不专门将它们放置在 IB 中,然后给它们特定的位置。
Hey, I've got a UIScrollView within my main view in the application, and I'm wondering what's the best way to place a set of labels and buttons within it. When I started, there was only a few, so I could physically place them in the interface builder, but now I've got more items to add to the ScrollView and can't fit them all on the screen in the interface builder. Is there a way to generate a sequence of buttons and labels? I just need them in an organized list, but I don't know how to generate content within the scrollview without specifically placing them in the IB, and then give them specific positions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我最终做的是使用界面生成器和屏幕上可见的对象(标签、按钮),并像使用界面生成器时那样对它们进行编码(即 UILabel *label; 在标题等中),然后使用界面生成器中的属性,设置它们的 x/y 位置,这会将它们移出屏幕,但由于它们是在我的滚动视图中编码的,因此它们在滚动视图中占据了自己的位置,并且可以向下滚动到。
Alright well what I ended up doing was using the interface builder with the objects visible on screen (Labels, buttons) and coding them as you would when you use the interface builder (i.e. UILabel *label; in the header etc.) and then using the properties in interface builder, set their x/y position, which would move them off the screen, but since they're coded within my scrollview, they take up their spot in the scrollview, and can be scrolled down to.