0

To clarify I am not looking for a tab bar on top. I am wondering if there's a solution using what already exists to create something like a TabHost/ViewPager in Android for iOS in Swift; i.e, the bar could be moved and would control a section of the screen (similar to fragments in Android). There are lots of questions offering partial solutions such as this and this mostly showing how to place tab bar on top.

Also I know containerView is supposed to be used to contain a view as part of the screen; however, managing all the communication between views is not a simple task and is error-prone. Below is a simple storyboard showing such a design.

I am wondering if there's a more efficient way to achieve a functionality similar to the tab bar in Instagram's home which is somewhat in the middle of the screen? Thanks for your input.

enter image description here

Community
  • 1
  • 1
TheBen
  • 3,410
  • 3
  • 26
  • 51

1 Answers1

0

In terms of a movable tab-bar, there's nothing out of the box as per the UIKit. You could possibly find something on https://www.cocoacontrols.com or similar sites which might fit the bill.

Failing that, you'd have to create a custom UIView to handle this.

In terms of handling the slit views e.g. top and bottom, it'd probably be better subclassing UIViewController and have that handle two container views as you have shown in your image.

As to communicating between viewControllers, it's not error prone in the slightest. You either use the responder chain to pass messages up the chain, create or use references between one another e.g. self.parentViewController or self.presentingViewController and in more complex ways let myViewController = self.presentingViewController!.childViewControllers[0] as? MyViewControllerClass

Adrian Sluyters
  • 2,186
  • 1
  • 16
  • 21
  • Thanks for your answer, it does help. I just came across a nice example on a custom tab bar provided by codepath. I think that does the job nicely. I was about to delete my question but I accept your answer as it is useful and to close this. CodePath example: https://github.com/codepath/ios_guides/wiki/Creating-a-Custom-Tab-Bar – TheBen Sep 02 '16 at 06:15