Another newbie to swift here. I want my application to have four tabs on the bottom and inside one of the tabs I want to be able to swipe between two 'pager' style tabs.
I have been able to make the four tabs work at the bottom by starting a new tabbed app and adding two additional view controllers.
Then I tried adding a SwipeViewController (https://github.com/fortmarek/SwipeViewController) to one of the tabs and it worked but it overrode the entry point so all I see is the two SwipeView tabs without the TabController tabs on the bottom.
!I want this inside of the Home tab]1
I think the problem is in my delegate code as it is setting self.window?.rootViewController to the SwipViewController. Getting rid of that assignment makes the Tab Bar show back up, but it is black inside of the Home tab so it is still not working.
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
let navigationController = SecondViewController(rootViewController: pageController)
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
return true
}
I also tried getting the corresponding window for the "Home" tab from the storyboard and setting the navigation controller to that.
let secondViewControllerWindow = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Home").view.window
secondViewControllerWindow?.rootViewController = navigationController
secondViewControllerWindow?.makeKeyAndVisible()
But Home is still empty. Here is the ViewController code that is represented by the Home tab and should control the SwipViewController
import UIKit
class SecondViewController: SwipeViewController {
override func viewDidLoad() {
super.viewDidLoad()
let stb = UIStoryboard(name: "Main", bundle: nil)
let page_one = stb.instantiateViewController(withIdentifier: "nba") as UIViewController
let page_two = stb.instantiateViewController(withIdentifier: "mlb") as UIViewController
setViewControllerArray([page_one, page_two])
page_one.title = "NBA"
page_two.title = "MLB"
setFirstViewController(0)
equalSpaces = true
//setButtons(UIFont.systemFontOfSize(18), color: UIColor.blackColor())
//setSelectionBar(80, height: 3, color: UIColor.blackColor())
setButtonsOffset(40, bottomOffset: 5)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
My questions is similar to these other questions but I did not find an answer.