1

I have just started programming on iOS a couple of weeks ago, so sorry if these questions are really basic.

Short story: I am designing a CRM app that needs capturing a lot of customer data. I am trying to emulate a desktop app that uses tabbed forms. What would be the best way (technically and visually) to implement this on an iPad?

I need the following:

  • each tab (5-6 of them) to contain a number of fields (with labels) of various types, for which I would love to use specialized controls (eg uidatepicker, uipickerview/uisegmentedcontrol, textarea+stepper, switch etc.), not just raw text fields
  • ideally (actually this is a pretty key requirement) the UI would have to be generated programatically, so that a change of model wouldn't require manually adjusting the forms in IB
  • be able to switch between tabs without losing the data already entered in the current tab.

My progress so far, re. overall switching mechanism:

  • I initially thought to have the tabs switcher implemented as a segmented control, switching between different views as described in Matthias' comment here. Instantiating VCs on demand however means losing the data already entered (unless I'd implement some sort of caching, but I'm hoping for something simpler).

  • I'm now considering the much easier approach of switching views by showing/hiding them programatically, but I'm afraid this might use too much memory (I'm looking at possibly over 100 fields in total).

As for representing the form fields within each tab:

  • I could lay them out manually in IB (or as static cells in a tableview) but I'd really prefer not to do that, as it would basically mean the UI is hardcoded and hard to change
  • I'd prefer to create the interface programatically, but I don't know how easy it is to handle the different field types, attach popups (e.g. for datepickers for date fields), handle field events etc.

If someone has any pointers I could use, I'd really appreciate it.

TIA, Lucian

Community
  • 1
  • 1
lucianf
  • 547
  • 7
  • 17
  • Are you using UITabBarController for your tab based application? In which manner those tabs are? – Mrunal May 21 '12 at 18:36
  • Yes, I'm already using UITabBarController, but for the main sections of the app, so it's not an option to implement the form tabs as tab bar items. That's why I was looking at uisegmentedcontroller or something similar. The form tabs would have to be displayed in a subview and not take the full screen. – lucianf May 21 '12 at 19:30
  • I would suggest you to use Custom Buttons, which looks like UITabBarController. – Mrunal May 22 '12 at 05:46

1 Answers1

0

I think you're on the right track with one view controller, owning one view that then has sub-views that you hide/show as needed.

Broadly:

  • one top level UIView, which contains the tab buttons (use ordinary UIButtons for this), and owns several UIViews
  • Each UIView has the fields needed for each "tab"

Then to switch tabs, just hide one view and show another and all will be well.

I wouldn't worry about memory consumption - an iPad has easily enough memory for 100s of UI controls, since I don't expect you'd be doing lots of custom graphics. If you do run low on memory, you can always just create the controls as needed for each tab - it will take a bit longer to switch tabs, but would work.

As for programmatically laying things out: this is entirely possible. You have 2 basic options when creating an iPad UI - use XIB files (designed using the graphical designer in XCode), or doing it in code, typically in -viewWillAppear or -viewDidLoad. All the relevant things can be done - look at the docs for each UI control to figure out how to configure it.

Malcolm Box
  • 3,968
  • 1
  • 26
  • 44