Issues with StoryBoard ViewControllers in IOS Tabbed App

In the struggles of developing an IOS Tabbed App with Swift 1.2 and Xcode 6.3 based on MVC, I use Storyboard visuals instead of doing it programmatically because I'm not an experienced developer. In the image below, you can see the Architecture in the StoryBoard


StoryBoard architecture

The application consists of:

  • One TabBarController

    to four TabBar Items

  • Each Item

    has its own ViewController

    c StoryBoard

  • They are all associated with relationship seque

    (ViewControllers) in StoryBoard

  • Everyone ViewController

    in StoryBoard

    has its own Class

  • The last item is built in NavigationController

    because I am using the PageMenu project to enable a paging menu controller with two childrenViewControllers

The problems I have up to this point:

  • The two are child ViewControllers

    not related to Last TabBar Item

    in StoryBoard

    , as you can see in the picture above, only created in parent ViewController Class

    (PageMenuViewController1), usually this one PageMenu

    works but sometimes the last one TabBar Item

    disappears, I am very confused about this problem .
  • override func viewWillAppear

    the default child ViewController

    is called twice the first time I have println ("ClubsController viewWillAppear").

ViewControllers Code

import UIKit

class ClubsViewController: UIViewController, UITableViewDataSource{

  @IBOutlet var tableview:UITableView!

  let apiClient = ApiClient()

  var clubs: [Club]!

  override func viewWillAppear(animated: Bool) {

    println("ClubsController viewWillAppear")

    apiClient.clubsService.getList() { clubs, error in
      if clubs != nil {
        self.clubs = clubs
      else {
        println("error: \(error)")

  override func didReceiveMemoryWarning() {
    // Dispose of any resources that can be recreated.

  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.clubs?.count ?? 0

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->UITableViewCell {
    var cell = tableView.dequeueReusableCellWithIdentifier("clubObjectCell") as! ClubTableViewCell
    cell.clubObject = self.clubs?[indexPath.row]
    return cell



PageMenuViewController Code

import UIKit

class PageMenuViewController1: UIViewController {

  var pageMenu : CAPSPageMenu?

  override func viewDidAppear(animated: Bool) {

    println("PageMenuViewController1 viewWillAppear")

    // Array to keep track of controllers in page menu
    var controllerArray : [UIViewController] = []

    // Create variables for all view controllers you want to put in the
    // page menu, initialize them, and add each to the controller array.
    // (Can be any UIViewController subclass)
    // Make sure the title property of all view controllers is set
    // Example:
    var controller1 = storyboard!.instantiateViewControllerWithIdentifier("ClubsViewController")! as! ClubsViewController
    controller1.title = "CLUBS"
    var controller2 = storyboard!.instantiateViewControllerWithIdentifier("PartiesViewController")! as! PartiesViewController
    controller2.title = "PARTIES"

    // Customize page menu to your liking (optional) or use default settings by sending nil for 'options' in the init
    // Example:
    var parameters: [CAPSPageMenuOption] = [

    // Initialize page menu with controller array, frame, and optional parameters
    pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

    // Lastly add page menu as subview of base view controller view
    // or use pageMenu controller in you view hierachy as desired


Appreciate help to achieve best practices up to this point.


source to share

1 answer

I'm not familiar with CAPSPageMenu, but there is nothing wrong with the scenes in the storyboard not being segue related - it's just a convenience to help with transitions, and instantiating with it is instantiateViewControllerWithIdentifier

completely legal.

Something that stands out on your storyboard is how your table view controller is wired with a navigation view controller.

The navigation controller must be related to the tab bar controller, not the table view controller.

Here is a screenshot of what the connection should look like. This may be why you sometimes lose your tab.

Layout layout for tabs with navigation controller



All Articles