How can I change TabBarController selected Item from SideMenu?

53 Views Asked by At
import SideMenu
import UIKit

class SideMenuViewController: UITableViewController {

      //...

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.tabBarController?.selectedIndex = indexPath.row
        self.dismiss(animated: true)
    }
}
1

There are 1 best solutions below

0
Shabnam Siddiqui On

have a look here...

let appDelegate = UIApplication.shared.delegate as! AppDelegate

if let tabBarController = appDelegate.window!.rootViewController as? UITabBarController {
    tabBarController.selectedIndex = indexPath.row
}