Comments (14)
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.
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.
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.
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.
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.
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.
@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.
Mostly resolved by commit: 2aa3045.
from pkrevealcontroller.
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.
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.
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.
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.
- in FrontViewController.h:
- (void) printAnswer;
- in FrontViewController.m:
- (void)printAnswer
{
NSLog(@"PRINTING!");
}
- 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.
Thanks again! works very well!
from pkrevealcontroller.
Related Issues (20)
- Limit the pan gesture in the main view
- PKRevealController doesn't play well with unwind segues
- UIScreenEdgePanGestureRecognizer instead of UIPanGestureRecognizer
- LeftView and CenterView Controller both vertical scrollable
- Show left or right UIViewController programmatically. HOT 1
- revealController:willChangeToState firing too late
- It will flash in the first time HOT 1
- leftBarButtonItem
- How to do ajustment of leftview to statusbar in IOS8?
- Disable pan gesture on front VC when showing VCs from side HOT 1
- Difference to UISplitViewController HOT 1
- Panning doesn't work HOT 1
- Create new tag v2.0.7 for CocoaPod
- 2:Issues as need quick assistance
- Add tabbar
- Crashes When Attempting to Present Side View Multiple Times
- setFrontViewController deprecated, no replacement HOT 1
- PKReveal dead? HOT 3
- `prefersStatusBarHidden` is not called in the FrontViewController
- ViewController lost reference when push notification was being clicked and when the app was in background too
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkrevealcontroller.