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..

geekyaleks
  • 1,281
  • 3
  • 18
  • 29
  • Thats what the AutoResizingMask is for, all UIViews and UIViewControllers have it – Dan F Nov 14 '12 at 18:30
  • http://stackoverflow.com/questions/12414817/iphone-5-4-bottom-toolbar-not-responding [1]: http://stackoverflow.com/questions/12414817/iphone-5-4-bottom-toolbar-not-responding – iArezki Nov 14 '12 at 18:34
  • Is AutoResizingMask something I set in InterfaceBuilder, or something I add programmatically? – geekyaleks Nov 14 '12 at 18:43
  • @geekyaleks You can either set it programmatically or in InterfaceBuilder – Dan F Nov 14 '12 at 18:59
  • In IB, it is those funny red arrows you see below your view's size information. The arrows represent how the view's width or height will adjust with respect to the superview's width and height changes (again with respect to how it is laid out initially). And the bars represent how the position of the view will change with respect to the superview as it changes (is the left margin fixed? is the right margin fixed? etc) – Dan F Nov 14 '12 at 19:06

1 Answers1

1

If you are only using iOS 6, the easiest method would be to use Auto Layout and add a constraint in Interface Builder. The constraint would describe that the toolbar's bottom edge should be equal to the superview's bottom edge. You don't have to code specifically for a single device. To have the UITableView stretch to fill all the available space, again I would recommend using constraints on the UIScrollView (not UITableView, which sits inside the scroll view) to describe this behavior, e.g. The scroll view's top edge should equal the superview's top, left edge should equal the superview's left, bottom edge should equal the UIToolbar's top (In IB, a spacing constraint specifying that the spacing between the UIToolbar and the UIScrollView should equal 0), and right edge should equal the superview's edge.

If you can't use constraints, this behavior is specified using the struts and springs system that utilizes the autoresizingMask property on the view that specifies that the UITableView's parent-UIScrollView has a flexible width and height and the UIToolbar has a fixed height and a flexible with. You would manually position the UIScrollView and UIToolbar by setting their respective frame property that describes the x,y coordinates of the top-left edge as well as the width and height of the view.

Andrew
  • 7,630
  • 3
  • 42
  • 51
  • Thank you, I got the toolbar to appear on the bottom, no matter if it's iPhone 5 or iPhone 4 as the selected hardware device. I need to work out the tableview... – geekyaleks Nov 14 '12 at 20:24