0

I'm working on building a universal iOS configuration application for the iPhone/iPad. But the layouts ('views') for the iPad are considerably different from that of the iPhone. Considering that only the appearance of the application ('views') change w.r.t the device, what is the most efficient design approach i could follow?

Things I've already looked at

  1. I've looked at one strategy where different View controllers are loaded depending on the device in use. But this might be an overkill considering that the 'controls' are the same across devices and only the appearance of the application changes.

  2. The use of functions to resize the view frames to layout views as needed automatically. This does not help me much because there is a need to not only change the size of the views but load different views altogether depending on the device.

  3. To keep the viewController unchanged but configure the views inside the viewController differently. Right now this seems like the best way to do it, but the application is kinda heavy and it might become very messy in the long run. Or is there a very efficient way to do this?

Is there a design strategy for this? Or is there any way i can accomplish this efficiently while optimizing effort?

Sagar
  • 555
  • 9
  • 24

1 Answers1

0

The standard approach is to have different XIB files for iPhone and iPad, which the platform will select automatically if you name them right, e.g. myview~iPhone.xib and myview~iPad.xib.

You are concerned about inefficiency: I wouldn't worry about the file size as compiled XIB is quite compact.

In my apps I mostly use this approach, with some fragments of code to add or remove buttons for each platform. Simple views can just be set up to resize automatically using the standard struts-and-glue techniques.

Bryan
  • 11,398
  • 3
  • 53
  • 78
  • Thank you bryan! But is it possible to do the same without using the xib's? I say that for two reasons: Firstly, im not a big fan of using Xib's id rather do things programmatically. Secondly, the layouts are highly dynamic and require some level of customiztion and i'm not sure how i can achieve this using the Xib. Thoughts? – Sagar Sep 25 '12 at 07:53
  • Struts and glue techniques for iOS? Can you give me more information on how i can use this to resize views? – Sagar Sep 25 '12 at 08:08
  • Apologies, "struts and glue" is my shorthand; it's how I learned many years ago. In Apple terms I'm talking about autoResizingMask, in toolbars flexibleSpace and fixedSpace, and the new AutoLayout stuff in iOS 6. – Bryan Sep 25 '12 at 08:54
  • To set different layout in code without using XIB, you would just write two versions with an if-statement. In code you can be as flexible as you like. Maybe I don't understand your question: what is it you perceive as unknown? – Bryan Sep 25 '12 at 08:57
  • What if the views are dynamic on the screen, that changes w.r.t events that are pre defined, and if the changed view has a different set of actions (or call backs) that can be performed on it Then I'm not too sure about the level of customization the nib can give me. Any work arounds? – Sagar Sep 26 '12 at 08:40