问题描述
我应该如何在 iPhone 上创建类似于 Springboard(主屏幕)的 UI?我想要一个间隔均匀的按钮网格,其中包含可以响应按钮点击的图像.
How should I go about creating a UI similar to the Springboard (home screen) on the iPhone? I'd like a grid of evenly spaced buttons with images where I can respond to the button tap.
UITable 合适吗?我应该使用普通的 UIView 并在 DrawRect 中手动定位图标吗?是否有替代方案可以自动均匀地间隔按钮、允许重新组织并根据 iPhone 方向调整布局?
Is the UITable a good fit? Should I use a plain UIView and position the icons manually in DrawRect? Is there an alternative that will automatically evenly space the buttons, allow reorganization, and adjust the layout according to the iPhone orientation?
我来自 C#/Winforms 背景,现在正在使用 2.2.1 标头在 Open Toolchain 上开始 iPhone 开发.
I come from a C#/Winforms background and am just now starting iPhone development on the Open Toolchain with 2.2.1 headers.
推荐答案
您需要将您的图标(是某种 UIView)添加为跳板"视图的子视图.不需要自定义绘图,UITable 是绝对错误的方法.您只需进行数学运算以正确放置它们(通过设置它们的框架).
You need to add your icons (which are UIViews of some sort) as subviews of your "Springboard" view. No custom drawing needed, and a UITable is thh absolute wrong way to go. You just need to do the math to place them correctly (by setting their frame).
这篇关于如何创建像 iPhone 主屏幕这样的图标网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!