0

I have SearchBar and TabBar on a view which i created using CosmicMind Swift Material framework for swift (https://github.com/CosmicMind/Material). Below is the code i have for setting up the view:

window = UIWindow(frame: Screen.bounds)
    let tabBarControllers = [MySearchBar(rootViewController:ViewController2()), MySearchBar2(rootViewController:ViewController1())]
    window!.rootViewController = TabBarController(viewControllers: tabBarControllers)
    window!.makeKeyAndVisible()

So basically, I have tab bar, which has search bar which in turn has a view. I created a xib for the view so that I can drag and drop and position things with the interface builder. The problem I am running to is that, the tab bar is covering some of my labels. See the screenshot below screenshot of my UIView

When i run my app I get the view shown below. As you can see the label 2 is out of view, I have tried everything possible but cant figure it out and to make the view fit between the search bar and the tab bar correctly

image after running my app

Any help will be greatly appreciated

My screenshot of my XIB view in xcode:xib screenshot

tigg
  • 107
  • 8

1 Answers1

1

The way you are approaching this may turn out more complicated than necessary. What you should do, if you are going to have a SearchBar on both pages of the TabBar, is set the TabBar as the child (rootViewController) of the SearchBar, so there will only be one instance of each. Then add constraints for auto layout within your view controller that has the labels. That should work for you :)

CosmicMind
  • 1,499
  • 1
  • 10
  • 6
  • I changed it to` window!.rootViewController = MySearchBarController(rootViewController:MyTabBarController(viewControllers: tabBarControllers))` but when the view loads, the search bars displays correctly but the tab bar doesnt appear/show – tigg Jun 12 '17 at 21:39
  • 1
    If you can share a sample project with this setup, I can take a look. – CosmicMind Jun 13 '17 at 16:58