Open isaacraja15 opened 5 years ago
Hey, Thanks.
You can use following function of FAPanels but you need to update it little bit.
func isTopVC(_ root: UIViewController?) -> Bool {
if root is UINavigationController {
let nav: UINavigationController = root as! UINavigationController
return nav.viewControllers.count == 1
}
else if root is UITabBarController {
let tab: UITabBarController = root as! UITabBarController
return isTopVC(tab.selectedViewController!)
}
return root != nil
}
To get the topViewController just return the root in above function in last line.
oh great , thanks bro, But what parameter i need to pass ? i'm using bluetooth BLE background service so some function need view identification for reload that view and pass the data to the view .
below the code is not BLE Module . i like your menu so i need to implement in my project so i try in simple menu project . could you help me to get current viewcontroller ?
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
print("qq")
if var topController = UIApplication.shared.keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
print(topController)
let isss = isTopVC(topController)
print(isss)
// topController should now be your topmost view controller
}
}
i just try this method but is showing same
qq <menu.FAPanelController: 0x102811c00> true Executing block after changing center panelVC From Left Menu rr qq <menu.FAPanelController: 0x102811c00> true rr qq <menu.FAPanelController: 0x102811c00> true
when you reach to FAPanelController try getting its centre view controller and check its type. I think you need that.
are you saying need to pass centre view controller ?
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let cv = storyboard.instantiateViewController(withIdentifier: "CenterVC1") as! CenterVC
let isss = isTopVC(cv)
print(isss)
Hi Bro, I try your Menu Its working Good . Great Job I have one Problem . I need top view controller / Current View Controller how to i get ?
I try this method its showing <menu.FAPanelController: 0x102014e00> i need Current View Controller not this one Thank you
Isaac