Giter VIP home page Giter VIP logo

Comments (14)

barbosa avatar barbosa commented on July 19, 2024

Do you know when you will add some example with communication between the Rear and the Front VC? I will really appreciate it :)

It's a really great project.
Thanks!

from pkrevealcontroller.

schimanke avatar schimanke commented on July 19, 2024

I'd really love to see this too. For example having a tableviewcontroller as the rear view, then selecting a table row would update the front view accordingly. Besides that selecting a row would push the front view over the rear view again. Just like Facebook does... :-)

from pkrevealcontroller.

bri3d avatar bri3d commented on July 19, 2024

When you're in the rear view, self.parentViewController will be the ZUUIRevealController, so you have access to the frontViewController property from there.

Using that knowledge it's easy to send messages to the frontViewController - and if the frontViewController is a NavigationController, it's trivial to just send it setViewControllers with the ViewController you selected in the rear view, then to call revealToggle on parentViewController to cause the front controller to slide into view.

from pkrevealcontroller.

bri3d avatar bri3d commented on July 19, 2024

Alternately, you can also do what I did, and have the two ViewControllers talk through a custom delegate which is set up when the VCs are initialized, which seems cleaner but isn't as generic a solution as "just use parentViewController."

from pkrevealcontroller.

pkluz avatar pkluz commented on July 19, 2024

Perfectly explained @bri3d :)

Although I'm still trying to come up with a good - universal - solution for that problem.There's gotta be a way to achieve that without the two (or more, if we consider the possibility of the frontview suddenly changing to a different one) controllers knowing who they are exactly and still have this work in an understandable and easy way without testing for what class it is, whether it responds to a certain selector or whatnot... But I think I'm looking for the holy grail right here. Guess I'll have to pick the best out of a few not-so-awesome solutions and promote it...thoughts?

from pkrevealcontroller.

schimanke avatar schimanke commented on July 19, 2024

Thanks for your input. I've been playing around a bit with your suggestions, bri3d, but still couldn't figure out how to update the front view and move it over the rear view again. I have not implemented the tableview on the rear view yet but I have put a button on it which should perform the action. Since I wasn't able to achieve what I want to do, I found out that self.parentViewController is not the ZUUIRevealController, but the RevealController. Could that be the reason why I am not able to call revealToggle on parentViewController as well? I am quite new to iOS development. So sorry if my questions are a bit silly but I am really stuck here...

from pkrevealcontroller.

pkluz avatar pkluz commented on July 19, 2024

@schimanke I assume you refer to the example project I provided with the library. Yes, in the example the parentViewController is the RevealController. But the RevealController is a subclass of ZUUIRevealController and all the necessary properties are inherited. Therefore the "RevealController" class also has a property called frontViewController and rearViewController :-)

from pkrevealcontroller.

pkluz avatar pkluz commented on July 19, 2024

Mostly resolved by commit: 2aa3045.

from pkrevealcontroller.

schimanke avatar schimanke commented on July 19, 2024

Thanks! FYI, I didn't manage to get it done but I worked around it by using notifications... Not perfect, but working. Having a look at your solution tonight.

from pkrevealcontroller.

nervouscat avatar nervouscat commented on July 19, 2024

Hi pkluz,
I am still facing some issues with this, for example, I create custom functions in the frontviewcontroller, how can I access them from any of the rearviewcontrollers, it does not seem like I can.

Thank you in advance!

from pkrevealcontroller.

pkluz avatar pkluz commented on July 19, 2024

In the rear view controller you can access self.revealCotroller.frontViewController.After casing correctly you can call your methods.

Note: If your rear view controller is nested im some other container (e.g. a UINavigationController or a UITabbarController) you will have access to the revealController by moving one step up the hierarchy like so:
self.parentViewController.revealController.frontViewController.

Sent from my iPhone

On Tue, Apr 23, 2013 at 6:28 PM, nervouscat [email protected]
wrote:

Hi pkluz,
I am still facing some issues with this, for example, I create custom functions in the frontviewcontroller, how can I access them from any of the rearviewcontrollers, it does not seem like I can.

Thank you in advance!

Reply to this email directly or view it on GitHub:
#6 (comment)

from pkrevealcontroller.

nervouscat avatar nervouscat commented on July 19, 2024

Thank you for your swift response!

Just to be more precise, in the example you provided id I added the following:

FrontViewController.h:
-(void) printAnswer;

FrontViewController.m:
-(void)printAnswer
{
NSLog(@"PRINTING!");
}

RightDemoControlView:
(in any of the button methods:)
[self.revealController.frontViewController printAnswer];

would this by any chance work? I tried it myself with no luck, I feel like im missing something.

Thanks again pkluz!

from pkrevealcontroller.

pkluz avatar pkluz commented on July 19, 2024
  1. in FrontViewController.h:
    - (void) printAnswer;
  2. in FrontViewController.m:
- (void)printAnswer
{
    NSLog(@"PRINTING!");
}
  1. in RightDemoViewController.m
    3.1. At the top: #import "FrontViewController.h"
    3.2. In any of the button methods:
UINavigationController *frontControllerContainer = ((UINavigationController *)self.revealController.frontViewController);
FrontViewController *actualFrontViewController = (FrontViewController *)frontControllerContainer.topViewController;
[actualFrontViewController printAnswer];

Remember:

In the AppDelegate you create a front view controller like so:

// Step 1: Create your controllers.
UINavigationController *frontViewController = [[UINavigationController alloc] initWithRootViewController:[[FrontViewController alloc] init]];

Thus, the frontViewController is a UINavigationController whose rootViewController is the actually desired controller (The one you want to talk to).

Please note, that you might want to rethink your application architecture if such an amount of implicit knowledge (i.e. "which controller is where") is required.

from pkrevealcontroller.

nervouscat avatar nervouscat commented on July 19, 2024

Thanks again! works very well!

from pkrevealcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.