Comments (4)
I consider this problem to be too specific for me to solve it for you. The rationale behind it is as follows: Not everyone might appreciate this kind of behavior in every situation. Take the iPad as an example. It wouldn't make sense to disable user interaction with the FrontView on a screen that big.
I agree with the iPhone though. It doesn't make sense to have the user still be able to hit buttons or similar on the front view (if say in portrait mode) seeing how the area of interaction is about 40 points wide. Give or take.
Thus I provide you with a protocol you can conform to. The ZUUIRevealControllerDelegate.
The usual approach would be no different from what you do when subclassing UITableViewController.
-
Create a subclass:
@interface MyRevealController : ZUUIRevealController <ZUUIRevealControllerDelegate>
-
Assign the delegate to self.
-
Implement one of these to control the interaction/flow:
- (BOOL)revealController:(ZUUIRevealController*)revealController shouldRevealRearViewController:(UIViewController*)rearViewController;
- (BOOL)revealController:(ZUUIRevealController*)revealController shouldHideRearViewController:(UIViewController*)rearViewController;
- (void)revealController:(ZUUIRevealController*)revealController willRevealRearViewController:(UIViewController*)rearViewController;
- (void)revealController:(ZUUIRevealController*)revealController didRevealRearViewController:(UIViewController*)rearViewController;
- (void)revealController:(ZUUIRevealController*)revealController willHideRearViewController:(UIViewController*)rearViewController;
- (void)revealController:(ZUUIRevealController*)revealController didHideRearViewController:(UIViewController*)rearViewController;
For example, in order to achieve your desired Path way, a quick and dirty solution would be:
- (void)revealController:(ZUUIRevealController *)revealController didRevealRearViewController:(UIViewController *)rearViewController { UIView *touchIntercepterView = [[UIView alloc] initWithFrame:revealController.frontViewController.view.frame]; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:revealController action:@selector(revealToggle:)]; [touchIntercepterView addGestureRecognizer:tapGestureRecognizer]; [tapGestureRecognizer release]; [revealController.frontViewController.view insertSubview:touchIntercepterView atIndex:INT_MAX]; [touchIntercepterView release]; } - (void)revealController:(ZUUIRevealController *)revealController didHideRearViewController:(UIViewController *)rearViewController { NSArray *subviews = [revealController.frontViewController.view subviews]; UIView *touchInterceptionView = [subviews lastObject]; [touchInterceptionView removeFromSuperview]; }
Note: I don't recommend using the snippet above in production the way I just provided it. It makes my eyes bleed. That's just to show you how it can be done with the least amount of effort.
Nonetheless, everything you need to implement your custom behavior and device differentiation (iPhone <-> iPad) is available to you. You can even achieve a perfect recreation of the Facebook way by say,...swapping the "Back" button (if you popped a few things onto the navigation stack the "reveal" button disappears ,..obviously) with a "Reveal" button whenever didRevealRearViewController: is triggered and swapping it back once didHideRearViewController: occurred. Just some thoughts.
In the end it's up to you to make use of the barebones I provide.
Did that solve your issue or do you still think there should be something I should implement on my side? Please do elaborate I'm open to ideas :-)
from pkrevealcontroller.
The facebook/path behavior is so entirely expected for the iphone that being able to manipulate the front view controller (by default) is nearly a bug. Subclassing and delegation should be required for the uncommon behavior, not the (95%? )expect one.
I know I know: "patches welcome" :P
from pkrevealcontroller.
I added this to the touch interceptor view to more closely mimic facebook on the iPad, which allows you to drag the front view back into place in addition to tapping it.
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:revealController action:@selector(revealGesture:)];
[touchIntercepterView addGestureRecognizer:panGestureRecognizer];
from pkrevealcontroller.
One other small issue, this method - (void)revealController:(ZUUIRevealController *)revealController didHideRearViewController:(UIViewController *)rearViewController
can be called even when - (void)revealController:(ZUUIRevealController *)revealController didRevealRearViewController:(UIViewController *)rearViewController
was never called. Essentially, you can start to reveal the rearViewController with a pan gesture on the NavBar, and then cancel it. This causes the nav bar to disappear since it is the top subview. Here's what I'm using now:
@interface RevealController()
@property (nonatomic, retain) UIView *touchIntercepterView;
@end
@implementation RevealController
@synthesize touchIntercepterView;
- (id)initWithFrontViewController:(UIViewController *)frontViewController rearViewController:(UIViewController *)rearViewController
{
self = [super initWithFrontViewController:frontViewController rearViewController:rearViewController];
if (self)
{
self.delegate = self;
}
return self;
}
- (void)revealController:(ZUUIRevealController *)revealController didRevealRearViewController:(UIViewController *)rearViewController
{
if (self.touchIntercepterView)
return;
self.touchIntercepterView = [[UIView alloc] initWithFrame:revealController.frontViewController.view.frame];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:revealController action:@selector(revealToggle:)];
[self.touchIntercepterView addGestureRecognizer:tapGestureRecognizer];
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:revealController action:@selector(revealGesture:)];
[self.touchIntercepterView addGestureRecognizer:panGestureRecognizer];
[revealController.frontViewController.view insertSubview:self.touchIntercepterView atIndex:INT_MAX];
}
- (void)revealController:(ZUUIRevealController *)revealController didHideRearViewController:(UIViewController *)rearViewController
{
[self.touchIntercepterView removeFromSuperview];
self.touchIntercepterView = nil;
}
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.