FAPanel use from other viewcontroller
JayeshPoriya opened this issue · 6 comments
Hi,
This is not an issue, I need your help.
How can I use FAPanel from another view controller. I don't want to use FAPanel from appDelegate.
I have Signin View Controller after successfully signin I want to use FAPanel.
I already set root view controller is signin view controller.
How can I use FAPanels after user signin? I want to use FAPanel in my signin view controller.
my view controller name is
- LeftViewController
- HomeViewController
- not use right view controller so I passed nill
My Code is which is used in a signin view controller
//====FAPanel for XIB
let centerVC = HomeViewController(nibName: "HomeViewController", bundle: nil)
let leftMenuVC = LeftViewController(nibName: "LeftViewController", bundle: nil)
let centerNavVC = UINavigationController(rootViewController: centerVC)
let window = UIWindow(frame: UIScreen.main.bounds)
// let appDelegate = UIApplication.shared.delegate as! AppDelegate
let rootController: FAPanelController = window.rootViewController as! FAPanelController
_ = rootController.center(centerNavVC).left(leftMenuVC).right(nil)
window.makeKeyAndVisible()
But this code is not working.
Can you please help me!
I face this type of issue as well
Could not cast value of type 'UINavigationController' (0x10b719ed8) to 'appname.FAPanelController' (0x106fc41f8).
2018-03-09 16:05:07.504574+0530 appname[28149:682526] Could not cast value of type 'UINavigationController' (0x10b719ed8) to 'appname.FAPanelController' (0x106fc41f8).
No. 1
you can use FAPanels from a UIViewController but for that you need to understand working of FAPanels.
Working
- Create your controllers (Centre, Left and Right)
- Create a new FAPanel controller and assign the above controllers to it
- Set the newly created FAPanels controller as your root window controller
Here is how it should be implemented
Create the controllers required
In your signin view controller, Add these :
let leftMenuVC = LeftViewController(nibName: "LeftViewController", bundle: nil)
let centerVC = HomeViewController(nibName: "HomeViewController", bundle: nil)
let centerNavVC = UINavigationController(rootViewController: centerVC)
Create the FAPanels controller
let panelVC = FAPanelController()
Set newly created FAPanels controller as the root window controller
_ = panelVC.center(centerNavVC)
UIApplication.shared.keyWindow?.rootViewController = panelVC
For animating the change from Sign in controller to your new home controller, Add the above two lines in a transition block like below,
UIView.transition(from: self.view, to: centerVC.view, duration: 0.5, options: UIViewAnimationOptions.transitionCrossDissolve) { (finished) in _ = panelVC.center(centerNavVC) UIApplication.shared.keyWindow?.rootViewController = panelVC }
Please let me know in case you need any further help. Thanks for using FAPanels 👍
Hi, i'm trying to use FAPanels. i have installed pods and in my root view controller given it class to FAPanelController, and written the code in app delegate as u have said but getting this error "Use of undeclared type 'FAPanelController'".How i can fix this? Another thing is that how can i access the same panel from another view controller? Is this panel will run fine if i want LeftMenu and tab bar in my application?
No.1
Import the FAPanles framework in your app delegate class.
No.2
You can simply access by panel property of any UIViewController.
i.e : self.panel
@fahidattique55
Thank you for replay!
Now it's working.
let panelVC = FAPanelController()
Thanks! This is useful.