PPRevealSideViewController Class Reference
Inherits from | UIViewController |
Conforms to | UIGestureRecognizerDelegate |
Declared in | PPRevealSideViewController.h |
Overview
Allow pushing controllers on side views.
This controller allows you to push views on sides. It is just as easy as a UINavigationController to use. It works on both iPhone and iPad, is fully compatible with non ARC and ARC projects.
Initializing
MainViewController *main = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main];
_revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];
self.window.rootViewController = _revealSideViewController;
Pushing a controller
You have several options to push a controller. The easiest way is :
PopedViewController *c = [[PopedViewController alloc] initWithNibName:@"PopedViewController" bundle:nil ];
[self.revealSideViewController pushViewController:c onDirection:PPRevealSideDirectionBottom animated:YES];
This will push the controller on bottom, with a default offset. You have four directions :
PPRevealSideDirectionBottom
PPRevealSideDirectionTop
PPRevealSideDirectionLeft
PPRevealSideDirectionRight
Popping
To go back to your center controller from a side controller, you can pop :
[self.revealSideViewController popViewControllerAnimated:YES];
If you want to pop a new center controller, then do the following :
MainViewController *c = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:c];
[self.revealSideViewController popViewControllerWithNewCenterController:n animated:YES];
Pushing from a side
If you are for example on the up side, and you want to push a controller on the left, you could call a method on your center controller asking him to display a left controller. But I thought it would be more convenient to provide a way to push an old controller directly. So, using the following will do the trick
[self.revealSideViewController pushOldViewControllerOnDirection:PPRevealSideDirectionLeft animated:YES];
If you are on top, and you want to push a new controller on top (why not), the default behavior of the controller would be to close the top side since it’s open. But you can force it to pop push :
[self.revealSideViewController pushViewController:c onDirection:PPRevealSideDirectionTop animated:YES forceToPopPush:YES];
Note if you don’t have controllers for all the sides
If you want to present only a controller on the left and the right for example, you probably don’t want the bouncing animation which shows that there is not yet a controller to present. This animation comes when you do a panning gesture with no preloaded controller, or no controller pushed yet on the triggered side. In that case, do the following
[self.revealSideViewController setDirectionsToShowBounce:PPRevealSideDirectionLeft | PPRevealSideDirectionRight];
You could also don’t want these animations at all. Disabled these like it
[self.revealSideViewController setDirectionsToShowBounce:PPRevealSideDirectionNone];
Tasks
Other Methods
-
rootViewController
Getter for the rootViewController
property -
options
The Reveal options. Possible values are :
property -
bouncingOffset
The offset bouncing. When opening, if set to -1.0, then the animation will bounce with a default offset When closing, if set to -1.0, then the animation open completely before closing. Set to -1.0 by default
property -
panInteractionsWhenClosed
For panning gestures Define the interactions to display the side views when closed. By default, only the navigation bar is enabled Possible values are :
property -
panInteractionsWhenOpened
For panning gestures Define the interactions to close the side view when opened. By default, all the view is enabled
property -
tapInteractionsWhenOpened
For tapping gestures Define the interactions to close the side view when opened. By default, all the view is enabled
property -
directionsToShowBounce
Define the side you want them to bounce if there is no controller. By default, all the side are enabled
property -
delegate
The delegate which will receive events from the controller. See PPRevealSideViewControllerDelegate for more informations.
property
Init method
-
– initWithRootViewController:
Initialize the reveal controller with a rootViewController. This rootViewController will be in the center.
Pushing and popping methods
-
– pushViewController:onDirection:animated:
Push controller with a direction and a default offset.
-
– pushViewController:onDirection:animated:forceToPopPush:
Push controller with a direction and a default offset and force to pop then push.
-
– pushOldViewControllerOnDirection:animated:
Push the old controller if exists for the direction with a default offset. This allows you for example to go directly on an another side from a controller in a side.
-
– pushViewController:onDirection:withOffset:animated:
Same as pushViewController:onDirection:animated: but with an offset
-
– pushViewController:onDirection:withOffset:animated:forceToPopPush:
Same as pushViewController:onDirection:animated:forceToPopPush: but with an offset
-
– pushOldViewControllerOnDirection:withOffset:animated:
Same as pushOldViewControllerOnDirection:animated: but with an offset
-
– popViewControllerWithNewCenterController:animated:
Pop controller with a new Center controller.
-
– popViewControllerAnimated:
Go back to the center controller.
More functionalities
-
– preloadViewController:forSide:
Preload a controller. Use only if the animation scratches OR if you want to have gestures on the center view controller without pushing first. Preloading is not good for performances since it uses RAM for nothing. Preload long before pushing the controller (ex : in the view did load) Offset set to Default Offset
-
– preloadViewController:forSide:withOffset:
Same as preloadViewController:forSide: but with an offset.
-
– unloadViewControllerForSide:
Remove the controller for a direction. This a convenient method when you use for example a Container view controller like Tab bar controller. When you switch from tabs, you probably want some tabs not to have side controllers. In that case, unload in view will disappear of the tab’s controller, then preload on view will appear.
-
– changeOffset:forDirection:
Change the offset for a direction. Not animated.
-
– changeOffset:forDirection:animated:
Same as – (void) changeOffset:(CGFloat)offset forDirection:(PPRevealSideDirection)direction but animated
-
– setOption:
Set Option.
-
– resetOption:
Reset Option.
-
– updateViewWhichHandleGestures
Update the view with gestures. Should be called for example when used with controllerForGesturesOnPPRevealSideViewController delegate method when using a container controller as the root. For example with a UITabBarController, call this method when the selected controller has been updated
Properties
bouncingOffset
The offset bouncing. When opening, if set to -1.0, then the animation will bounce with a default offset When closing, if set to -1.0, then the animation open completely before closing. Set to -1.0 by default
@property (nonatomic, assign) CGFloat bouncingOffset
Declared In
PPRevealSideViewController.h
delegate
The delegate which will receive events from the controller. See PPRevealSideViewControllerDelegate for more informations.
@property (nonatomic, assign) id<> delegate
Declared In
PPRevealSideViewController.h
directionsToShowBounce
Define the side you want them to bounce if there is no controller. By default, all the side are enabled
@property (nonatomic, assign) PPRevealSideDirection directionsToShowBounce
Declared In
PPRevealSideViewController.h
options
The Reveal options. Possible values are :
@property (nonatomic, assign) PPRevealSideOptions options
Discussion
- PPRevealSideOptionsNone = 0
- PPRevealSideOptionsShowShadows = 1 << 1 Disable or enable the shadows. Enabled by default
- PPRevealSideOptionsBounceAnimations = 1 << 2 Decide if the animations are boucing or not. By default, they are
- PPRevealSideOptionsCloseCompletlyBeforeOpeningNewDirection = 1 << 3 Decide if we close completely the old direction, for the new one or not. Set to YES by default
- PPRevealSideOptionsKeepOffsetOnRotation = 1 << 4 Keep the same offset when rotating. By default, set to no
- PPRevealSideOptionsResizeSideView = 1 << 5 Resize the side view. If set to yes, this disabled the bouncing stuff since the view behind is not large enough to show bouncing correctly. Set to NO by default
Declared In
PPRevealSideViewController.h
panInteractionsWhenClosed
For panning gestures Define the interactions to display the side views when closed. By default, only the navigation bar is enabled Possible values are :
@property (nonatomic, assign) PPRevealSideInteractions panInteractionsWhenClosed
Discussion
- PPRevealSideInteractionNone = 0
- PPRevealSideInteractionNavigationBar = 1 << 1
- PPRevealSideInteractionContentView = 1 << 2
Declared In
PPRevealSideViewController.h
panInteractionsWhenOpened
For panning gestures Define the interactions to close the side view when opened. By default, all the view is enabled
@property (nonatomic, assign) PPRevealSideInteractions panInteractionsWhenOpened
Declared In
PPRevealSideViewController.h
rootViewController
Getter for the rootViewController
@property (nonatomic, readonly, retain) UIViewController *rootViewController
Declared In
PPRevealSideViewController.h
Instance Methods
changeOffset:forDirection:
Change the offset for a direction. Not animated.
- (void)changeOffset:(CGFloat)offset forDirection:(PPRevealSideDirection)direction
Parameters
- offset
The offset
- direction
The direction for which to change the offset
Declared In
PPRevealSideViewController.h
changeOffset:forDirection:animated:
Same as – (void) changeOffset:(CGFloat)offset forDirection:(PPRevealSideDirection)direction but animated
- (void)changeOffset:(CGFloat)offset forDirection:(PPRevealSideDirection)direction animated:(BOOL)animated
Parameters
- offset
The offset
- direction
The direction for which to change the offset
- animated
Animated or not
Declared In
PPRevealSideViewController.h
initWithRootViewController:
Initialize the reveal controller with a rootViewController. This rootViewController will be in the center.
- (id)initWithRootViewController:(UIViewController *)rootViewController
Parameters
- rootViewController
The center view controller.
Return Value
the controller initialized
Declared In
PPRevealSideViewController.h
popViewControllerAnimated:
Go back to the center controller.
- (void)popViewControllerAnimated:(BOOL)animated
Parameters
- animated
Animated or not
Declared In
PPRevealSideViewController.h
popViewControllerWithNewCenterController:animated:
Pop controller with a new Center controller.
- (void)popViewControllerWithNewCenterController:(UIViewController *)centerController animated:(BOOL)animated
Parameters
- centerController
The new center controller
- animated
Animated or not
See Also
Declared In
PPRevealSideViewController.h
preloadViewController:forSide:
Preload a controller. Use only if the animation scratches OR if you want to have gestures on the center view controller without pushing first. Preloading is not good for performances since it uses RAM for nothing. Preload long before pushing the controller (ex : in the view did load) Offset set to Default Offset
- (void)preloadViewController:(UIViewController *)controller forSide:(PPRevealSideDirection)direction
Parameters
- controller
The controller to preload
- direction
The direction for the future controller
Discussion
For example, you will use as it, with a performSelector:afterDelay: (because of some interferences with the push/pop methods)
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadLeft) object:nil];
[self performSelector:@selector(preloadLeft) withObject:nil afterDelay:0.3];
}
- (void) preloadLeft {
TableViewController *c = [[TableViewController alloc] initWithStyle:UITableViewStylePlain];
[self.revealSideViewController preloadViewController:c
forSide:PPRevealSideDirectionLeft
withOffset:_offset];
}
Declared In
PPRevealSideViewController.h
preloadViewController:forSide:withOffset:
Same as preloadViewController:forSide: but with an offset.
- (void)preloadViewController:(UIViewController *)controller forSide:(PPRevealSideDirection)direction withOffset:(CGFloat)offset
Parameters
- controller
The controller to preload
- direction
The direction for the future controller
- offset
The offset
See Also
Declared In
PPRevealSideViewController.h
pushOldViewControllerOnDirection:animated:
Push the old controller if exists for the direction with a default offset. This allows you for example to go directly on an another side from a controller in a side.
- (void)pushOldViewControllerOnDirection:(PPRevealSideDirection)direction animated:(BOOL)animated
Parameters
- direction
The direction
- animated
Animated or not
Declared In
PPRevealSideViewController.h
pushOldViewControllerOnDirection:withOffset:animated:
Same as pushOldViewControllerOnDirection:animated: but with an offset
- (void)pushOldViewControllerOnDirection:(PPRevealSideDirection)direction withOffset:(CGFloat)offset animated:(BOOL)animated
Parameters
- direction
The direction
- offset
The offset when the side view is pushed
- animated
Animated or not
Declared In
PPRevealSideViewController.h
pushViewController:onDirection:animated:
Push controller with a direction and a default offset.
- (void)pushViewController:(UIViewController *)controller onDirection:(PPRevealSideDirection)direction animated:(BOOL)animated
Parameters
- controller
The controller to push
- direction
This parameter allows you to choose the direction to push the controller
- animated
Animated or not
See Also
Declared In
PPRevealSideViewController.h
pushViewController:onDirection:animated:forceToPopPush:
Push controller with a direction and a default offset and force to pop then push.
- (void)pushViewController:(UIViewController *)controller onDirection:(PPRevealSideDirection)direction animated:(BOOL)animated forceToPopPush:(BOOL)forcePopPush
Parameters
- controller
The controller to push
- direction
This parameter allows you to choose the direction to push the controller
- animated
Animated or not
- forcePopPush
This parameter is needed when you want to push a new controller in the same direction. For example, you could push a new left controller from the left. In this case, setting forcePopPush to YES will pop to center view controller, then push the new controller.
Declared In
PPRevealSideViewController.h
pushViewController:onDirection:withOffset:animated:
Same as pushViewController:onDirection:animated: but with an offset
- (void)pushViewController:(UIViewController *)controller onDirection:(PPRevealSideDirection)direction withOffset:(CGFloat)offset animated:(BOOL)animated
Parameters
- controller
The controller to push
- direction
The direction of the push
- offset
The offset when the side view is pushed
- animated
Animated or not
Declared In
PPRevealSideViewController.h
pushViewController:onDirection:withOffset:animated:forceToPopPush:
Same as pushViewController:onDirection:animated:forceToPopPush: but with an offset
- (void)pushViewController:(UIViewController *)controller onDirection:(PPRevealSideDirection)direction withOffset:(CGFloat)offset animated:(BOOL)animated forceToPopPush:(BOOL)forcePopPush
Parameters
- controller
The controller to push
- direction
This parameter allows you to choose the direction to push the controller
- offset
The offset when the side view is pushed
- animated
Animated or not
- forcePopPush
This parameter is needed when you want to push a new controller in the same direction. For example, you could push a new left controller from the left. In this case, setting forcePopPush to YES will pop to center view controller, then push the new controller.
Declared In
PPRevealSideViewController.h
resetOption:
Reset Option.
- (void)resetOption:(PPRevealSideOptions)option
Parameters
- option
The option to reset
Declared In
PPRevealSideViewController.h
setOption:
Set Option.
- (void)setOption:(PPRevealSideOptions)option
Parameters
- option
The option to set
Declared In
PPRevealSideViewController.h
unloadViewControllerForSide:
Remove the controller for a direction. This a convenient method when you use for example a Container view controller like Tab bar controller. When you switch from tabs, you probably want some tabs not to have side controllers. In that case, unload in view will disappear of the tab’s controller, then preload on view will appear.
- (void)unloadViewControllerForSide:(PPRevealSideDirection)direction
Parameters
- direction
The direction for which to unload the controller
Declared In
PPRevealSideViewController.h
updateViewWhichHandleGestures
Update the view with gestures. Should be called for example when used with controllerForGesturesOnPPRevealSideViewController delegate method when using a container controller as the root. For example with a UITabBarController, call this method when the selected controller has been updated
- (void)updateViewWhichHandleGestures
Declared In
PPRevealSideViewController.h