Hello, I am new to iOS programming. I am trying to build an iOS application that allows the user to create, view and edit family trees by adding new persons, their name and details, creating relationships between two or more persons etc. The main interface of the application should show a tree structure fanning out downwards. It will show nodes and edges. The nodes that will show the name and picture of the person should respond to taps and deep presses for editing and making connections. The interface should be scrollable left-right, up-down. Also the tree structure should respond to different size classes.
I am confused regarding how to draw/create this interface. My choices are: (I may be wrong about the capability of some as I am a newbie)
- Use a collection view to get a grid type layout and populate specific cells with nodes. The edges will be drawn by CoreGraphics. This is a somewhat messy solution because Collection views allow access to cells of particular row whereas I need the x and y coordinates to be absolute for the node in a particular size class. I am also not sure about drawing lines over the flow layout for the edges and how different size classes will affect the interface.
- Use a simple UIView and place custom views created programmatically on it. The custom view will have an image and labels. Lines will again be drawn using CoreGraphics. This is again somewhat complicated and I am not sure about how chaning the orientation/device will affect the picture.
- Use some Game Kit. I have zero knowledge of any game kit but I will be very grateful if someone can direct me to the best option to accomplish my task.
Any help will be greatly appreciated.
If you need flexibility in your drawing, I recommend option 2 : custom drawing.
When you change orientation, the drawRect function will be called to redraw everything ; that should not be a problem.
probably the tricky part will be to build the data model chaining all the nodes data.
If you need, there are many code samples for this.
Look at h ttps://www.codeproject.com/Articles/531953/Family-Tree It's not Swift, but interesting to read.
Or this one on tree's structure
h ttps://www.raywenderlich.com/138190/swift-algorithm-club-swift-tree-data-structure