Closed vamsikrishnasurathi closed 6 years ago
Sorry but you are wrong. Here, it is PBRevealViewController not SWRevealViewController.
Actually the code was posted by using 'SWRevealViewController' but later i tried 'PBRevealViewController' also but the both libraries almost resemble same and posted the question
Where do you want to come back from Account view controller? Always to Home view controller or to the controller that was selected when you pushed the account view controller?
any how thanks for reply @iDevelopper i got the required with SWRevealViewController
but let me know how to implement the same using PBRevealViewController
when selecting back button in rear view controllers to go back to home page or which ever selected page in tab bar in main view controllers
Can the account view controller be able to open the side menu or no? If yes, how? With another button as there is already a back button...
No there is no chance to open side menu in my account page only back button will be there to come back to previous view controller
Here is a sample with SW:
If you need some help for PBRevealViewController please open a new issue at https://github.com/iDevelopper/PBRevealViewController
I tried to open the project but it didn't open and it shows error @iDevelopper
here is the error displayed
How to open this and i was using Xcode 9.2 ?
Try this one:
Thanks working perfectly but i also got the same thing with different code is it fine with this or should i need to replace like your code ?
for moving from side menu to another view controller
i had declared the code in left side view controller like this
var frontNVC: UINavigationController?
var frontVC: HomeViewController?
var secondVC : CategoriesViewController?
var thirdVC : BrandLandingViewController?
var fourthVC : OffersViewController?
var fifthVC : CartViewController?
var loginVC : LogInViewController?
using below code to move from main view controller to side menu view controllers
var controller: UIViewController? = nil
let storyboard = UIStoryboard(name: "Main", bundle: nil)
controller = storyboard.instantiateViewController(withIdentifier: controllers[indexPath.row])
if controller != nil
{
_ = frontNVC?.popViewController(animated: false)
if !(controller is HomeViewController) {
print(frontNVC)
frontNVC!.pushViewController(controller!, animated: false)
}
revealViewController().setFrontViewPosition(.left, animated: true)
}
To make view controller to come back to same main view controller i was using this code
let nc = revealViewController().rearViewController as? UINavigationController
let frontNVC = (nc?.topViewController as? LeftSideViewController)?.frontNVC
_ = frontNVC?.popViewController(animated: true)
And in the same main view controller i am initializing which navigation it was and the code is
let nc = revealViewController().rearViewController as? UINavigationController
(nc?.topViewController as? LeftSideViewController)?.frontNVC = self.navigationController
(nc?.topViewController as? LeftSideViewController)?.frontVC = self
It seems more complicated. Your frontNVC is the HomeVC navigation controller. What happen if you push from another tab? Where do you use your variable frontVC, secondVC, thirdVC etc... as you instantiate your controllers from storyboard each time?
if i push from another tab i will make the selected tab navigation code as shown in above code will come back and i am using the selected view controller variable here
let nc = revealViewController().rearViewController as? UINavigationController
(nc?.topViewController as? LeftSideViewController)?.frontNVC = self.navigationController
(nc?.topViewController as? LeftSideViewController)?.frontVC = self
any how your code was simple and works fine will try to change thanks for reply @iDevelopper
Here I am using
swrevealViewController
to display side menu and here I am having tab bar items for view controllers and for this tab bar view controllers will have bar buttons and which will be having action for side menu and here if I select any of the bar buttons in tab bar which will opens side menu and will have access to another view controllers in side menu after going to any view controller then when I press the back button action was working fine for first time and when I move to another view controller in tab bar then also it works fine whenever I move to previous tab bar view controller and later i click side menu view controllers then the view controller was moving in the previous navigation view controller and in the navigationfrontNVC
the last accessed new view controller was saving in navigation stack can you please help me how to resolve this ?here is the code which used for moving side menu in did select row delegate method
Here I am using swrevealViewController to display side menu and here I am having tab bar for five view controllers and in this every view controller need to have bar button and which will be having action for side menu and here if I select any of the bar buttons in tab bar which will opens side menu and will have access to another view controllers in side menu after going to any view controller then when I press the back button action was working fine and when I move to another to another view controller in tab bar after coming back from view controller then also it works fine whenever I move to previous tab bar view controller and click side menu view controllers then the view controller was moving in the previous navigation controller and in the navigation frontNVC the last accessed new view controller was saving in navigation stack so if i select any view controller in side menu when tab item was in home then the view controller was displaying in last selected tab bar item view controller not in the home view controller and first time after running app it was working fine later not works and here i am using tab bar and side menu for displaying Please help me how to resolve this ?
here is the code which used for moving side menu in did select row delegate method
if cell.titleCellLabel.text! == "Account" { var controller: UIViewController? = nil let storyboard = UIStoryboard(name: "Main", bundle: nil) controller = storyboard.instantiateViewController(withIdentifier: controllers[indexPath.row]) print(frontNVC?.viewControllers) if controller != nil { // Prevent stacking the same controller multiple times print(frontNVC) _ = frontNVC?.popViewController(animated: false) frontNVC?.viewControllers.removeAll() // Prevent pushing twice FrontTableViewController if !(controller is SWRevealViewController) { // Show the controller with the front view controller's navigation controller print(frontNVC) frontNVC!.pushViewController(controller!, animated: false) } // Set front view controller's position to left revealViewController().setFrontViewPosition(.left, animated: true) } }
@IBAction func backButtonAction( sender: Any) { let nc = revealViewController().rearViewController as? UINavigationController let frontNVC = (nc?.topViewController as? LeftSideViewController)?.frontNVC = frontNVC?.popViewController(animated: true) }