John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 989 forks source link

How to catch when front controller is pushed by the rear one? #487

Open devoloopsw opened 8 years ago

devoloopsw commented 8 years ago

Hi, I have some properties in my Main front ViewController that need to save when my rear is called and reload when my front is reallocated, because when reallocating it turns the properties on their default values (in viewDidLoad) but I rather would like to reload the parameters as before the rear calling. Don't really realize how to do this...maybe with segues? Thank you

iDevelopper commented 8 years ago

If you don't want the frontViewController to be reallocated each time, you can delete the segue in the storyboard. Then you could have a property of your frontViewController and instantiate it if the property is nil (the first time) programmatically like this :

    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"YourStroryboardName" bundle:nil];
    self.yourController = [storyBoard instantiateViewControllerWithIdentifier:@"YourControllerIdentifier"];

and push it with:

    [self.revealViewController pushFrontViewController:_yourController animated:YES];
zcelaloglu commented 8 years ago

Hi, I have only one storyboard which is Main how can I handle this issue with swift?

iDevelopper commented 8 years ago

What issue?

zcelaloglu commented 8 years ago

the issue is I would to stop the current active view controller from being reloaded when the cell in the side menu that is linked to it is selected. How can I achieve this with swift?

btw I don't have objective-c background :(

iDevelopper commented 8 years ago
let storyboard = UIStoryboard(name: "Main", bundle: nil)
self.yourController = storyboard.instantiateViewControllerWithIdentifier("YourControllerIdentifier") as! UIViewController

self.revealViewController?.pushFrontViewController(_yourController, animated: true)
zcelaloglu commented 8 years ago

where should I call this code block? and should I do for every VC ?

iDevelopper commented 8 years ago

When a cell is selected (didSelectRowAtIndexPath) in your menu. if your controller's property is not already set then instantiate the controller from your storyboard and set it, else push it directly.

zcelaloglu commented 8 years ago

my menu tableview is static I just push child VC from each static cell so there is no VC for it where can I trigger?

iDevelopper commented 8 years ago

??

zcelaloglu commented 8 years ago

my sw_rear is tableview VC but each row is not dynamic all of them static it means I added each cell manually in storyboard so there is no assigned tableview VC to it

iDevelopper commented 8 years ago

Provide a sample project please

zcelaloglu commented 8 years ago

project is private on bitbucket if u provide ur email address I can give authority to read my code or if u use TeamViewer or skype I can share my screen to show u all staff

iDevelopper commented 8 years ago

I did not ask to provide your project bu a sample. Can you create a new sample project?

zcelaloglu commented 8 years ago

ok I'm creating right now

zcelaloglu commented 8 years ago

I'm uploading project right now

zcelaloglu commented 8 years ago

https://github.com/Zfr21/SWRevealViewSample

iDevelopper commented 8 years ago

You have to create a new file (MenuTableViewController for example) and implement :

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
iDevelopper commented 8 years ago

https://github.com/iDevelopper/PBRevealViewController