0

I'am developing IOS Universal App , and stuck in a logic and UI similar to Contacts App IOS 7, basically i have guests list and user can add guest , guest has many keys and doors.Just like contact in contacts app each one has multiple phone numbers , emails , etc I searched for tutorials and tried the following:

1.Create a UIView on add Action , make container for keys and another for doors along with 2 buttons "add key" and "add door", but the problem is i need them to be table view instead of moving the below controls of each new added key or door down.

2.tried the UITableViewController inside UIViewController,stuck because i had tow tables and each one has to have dynamic cells and it was a mess.

3.Now i came up with something close :

  • I made UITableViewController , Dynamic cells. 2 sections and initialised mutable array with 2 objects each is an mutable array one for keys and the other for doors.

  • Tow xib for add key and add door actions each contain a button with a segue to add key or door subview to the corresponding section and then reloadData.

  • Another Tow xib for key entry template and door entry template.

Is there another approach should i take or that's fine , if you have a tutorial or something please help it's taking time like forever and as you can notice i'am a newbie in ios.

Mina Kolta
  • 1,551
  • 2
  • 12
  • 22

2 Answers2

1

I am having a hard time understanding your explanation, but if you're emulating the standard Contacts.app a single UITableView will work fine.

Use your datasource to control what rows and sections should appear and where, I recently did this by having an array of section objects which simply have a name and fields array that contains field objects as the elements. The field object dictates which type of UITableViewCell to display and what values they should contain. When I add/remove a phone number I update the data source and call the appropriate table view methods to animate the changes.

Here is a screenshot of the UI.

enter image description here

The data source for what is visible looks like the following....

NSArray
 - Section (General Info)
   - Fields
     - First Name
     - Last name
     - Company
     - Job Title
     - Phone
     - New Phone (special field that when tapped inserts another phone field)
     - Email
     - New Email (special field that when tapped inserts another email field)
  - Section (Addresses)
    - ... 
Chris Wagner
  • 20,773
  • 8
  • 74
  • 95
  • Sorry for inconvenience of writing the question , i wanted to explain it all,If you have suggestions for other please edit. The datasource array what helped me figuring the solution and am doing it now I'll keep posting here for other newbies. – Mina Kolta Jan 16 '14 at 18:41
  • @Chris Wagner I know it's been almost 7 yrs since you have answered this question, but by any chance, do you have this implementation store somewhere? I am trying to achieve the same in Swift. The goal is to create a UI similar to the contacts app but with custom fields. – Vishal Sonawane May 08 '21 at 14:54
  • Sorry, I do not. That was an implementation for an employer I’m not longer with (or could share in whole if I were). I think this type of screen would be easier these days with tools like https://developer.apple.com/documentation/uikit/uitableviewdiffabledatasource – Chris Wagner May 09 '21 at 15:21
0

I think first of all you should freeze your prototype. Maybe use a piece of paper and figure out what you would like. Just saying that UI should be similar to ios contacts app isnt going to help. Once you have the Ux the code will just flow

Karthik
  • 934
  • 9
  • 21