1

I have an app that is designed for the iPhone 4. This app has a toolbar that was drag-dropped in Interface Builder to the bottom of the screen. When testing on simulator's iPhone 5 "device", the toolbar does NOT automatically go to the bottom of the screen.

My question is - is there some kind of a trick or technique, that will let all the UITables "stretch" to populate all the new available space, and toolbars go to the bottom no matter what kind iPhone it is being connected to? It would be painful, to do this programmatically - that is figure out what kind of an iPhone I am and then, programmatically reposition all the ui. If this is in fact a must, should any new iPhone apps be designed for 4" retina, and then programmatically shrink everything for iPhone 4 size, or is it better to design for 3.5", and then stretch and push down toolbars in case it is an iPhone 5 with 4" screen.

Thanks for any input..

4

1 回答 1

1

如果您只使用 iOS 6,最简单的方法是使用 Auto Layout 并在 Interface Builder 中添加约束。约束将描述工具栏的底部边缘应该等于超级视图的底部边缘。您不必专门为单个设备编写代码。为了让 UITableView 拉伸以填充所有可用空间,我再次建议使用UIScrollView上的约束(不是 UITableView,它位于滚动视图内)来描述这种行为,例如滚动视图的顶部边缘应该等于超级视图的顶部,左侧edge 应该等于 superview 的左侧,bottom edge 应该等于 UIToolbar 的顶部(在 IB 中,间距约束指定 UIToolbar 和 UIScrollView 之间的间距应等于 0),

如果不能使用约束,则使用 struts 和 springs 系统指定此行为,该系统利用视图上的 autoresizingMask 属性,指定 UITableView 的父 UIScrollView 具有灵活的宽度和高度,而 UIToolbar 具有固定的高度和灵活的和。您可以手动定位 UIScrollView 和 UIToolbar,方法是设置它们各自的 frame 属性,该属性描述左上边缘的 x、y 坐标以及视图的宽度和高度。

于 2012-11-14T18:35:43.967 回答