Search code examples
iosswiftuitableviewuitabbar

Tab bar disappears when returning from modal view controller


I have a strange problem that I have not been able to resolve. I have a relatively large app with segues to modal view controllers from both UIViewControllers and UITableViewControllers. The UIViewControllers seem to work fine, however, I have an inconsistent problem with the table view controllers. The tab bar is displayed when I segue to the modal controller, and it displays correctly in the model view. However, when I dismiss the modal controller, there is a 50/50 chance that the tab bar on the table view controller will be gone. The background view extends right to the bottom of the screen. The tab bar is translucent, so I want the background to extend behind it, but I have no idea why in some instances (with same controllers and same situation) work correctly and some don't. I haven't been able to find any pattern.

Before segue to modal: enter image description here

Upon return from modal: enter image description here

Initial tableview controller:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if optionEnabled[indexPath.row] {
        let segues:[String] = ["profileMenuSegue", "servicesProvidedSegue", "myWorkDaySegue", "myWorkWeekSegue", "timeOffSegue", "myAvailabilitySegue", "staffSegue", "promoSegue", "activateAccountSegue", "addWeekSegue"]

        performSegueWithIdentifier(segues[indexPath.row], sender: self)
    }

}

Modal view controller:

Alamofire.request(.POST, url, parameters: params, encoding: ParameterEncoding.URL)
    .validate()
    .responseJSON { (request, _, result) in
        switch result {
        case .Success(let data):
            json = JSON(data)
            print(json)
            print("request successful")

            dispatch_async(dispatch_get_main_queue(), { () -> Void in
                self.dismissViewControllerAnimated(true, completion: nil)
            })
        case .Failure(_, let error):
            print("request failed")
            print(error)
    }
}

I've tried all the "Extend Edges" settings both on and off, and I've tried overriding the "Inferred" for both top bar and bottom bar. I have presentation set to "Current Context" on all view controllers.

Any suggestions greatly appreciated, as I am running out of things to try.


Solution

  • The only solution I could find that worked was to remove all modal segues. I switched them all over to "show" segues and haven't had a problem since. Must be something to do with the fact that I was not displaying the modal views full screen. I still had the tab bar on the bottom. When transitioning from the modal view back to the caller, there would often be a flash of colours at the tab bar, then sometimes the tab bar would come back, and other times it would be covered by the background.