1
votes

First sorry for my english. I have a UISplitViewController and i replaced the template master UITableViewController with an UIViewController put a UITableView and UIContainerView what contains a second static UITAbleViewController for settings one of this settings cell has another detail UITableViewController to change its value. on iPhone works well but on iPad with that splitviewcontroller this settings value table shows over on the splitviewcontroller detail view. its good too but i can't hide anymore. (On iPhone has a back button and just works well) I couldn't find the solution. My question is how can i hide that detail view to show the original detail view of the split view? Here are my 3 pics from storyboard, the initial view and when the settings values are opens(that can't be hide n iPad)

Any advice would be nice. Thanks Storyboard

Ipad screenshots

1

1 Answers

1
votes

Finally i made an easy solution. Delete show detail storyboard segue on settings tableviewcontroller and define didSelectRowAtIndexPath for custom push

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    //i want only the third row to perform an action
    if indexPath.row == 2 {
        let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let groupListViewController = mainStoryboard.instantiateViewControllerWithIdentifier("GroupListViewController") as! GroupListViewController
        self.navigationController!.pushViewController(groupListViewController, animated: true)
    }

}

This way i can push any view to the split view left or right side cos both have navigation controller. After this i defined the same function on the pushed tableviewcontroller fire some action and go back. It works like a charm on iPad and iPhone too.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        self.appDelegate.client.selectedGroupIndex = indexPath.row

        //The main master viewcontroller of split view
        let vehicleListViewController = self.navigationController?.viewControllers.first as! VehicleListViewController

        //settingsviewcontroller that embedded in master viewcontroller
        let vehicleListSettingsViewController = vehicleListViewController.childViewControllers.first as! VehicleListSettingsViewController

        //call a custom function on embedded settings viewcontroller to change selected value
        vehicleListSettingsViewController.changeGroup(indexPath.row)

        //refresh splitviewcontroller's master tableview
        vehicleListViewController.tableView.reloadData()

        //Easy go back to masterview
        self.navigationController?.popViewControllerAnimated(true)


    }