I am using SWRevealViewController in IOS app (universal). I'm getting sidebar in iPhone and iPad both but I want to show sidebar which covers 90% of screen - how can I?
Asked
Active
Viewed 6,016 times
6

Anbu.Karthik
- 82,064
- 23
- 174
- 143

Premal Khetani
- 3,175
- 1
- 26
- 58
-
it always covered the 90% of the View , can u show the screen shot which type u need – Anbu.Karthik Aug 07 '14 at 06:57
4 Answers
13
open the SWRevealViewController.m
file and then u get the _initDefaultProperties
Method. in this method you get the side screen size and position
- (void)_initDefaultProperties
{
_frontViewPosition = FrontViewPositionLeft;
_rearViewPosition = FrontViewPositionLeft;
_rightViewPosition = FrontViewPositionLeft;
_rearViewRevealWidth = 260.0f; /// this is the method u change the side bar width
_rearViewRevealOverdraw = 60.0f;
_rearViewRevealDisplacement = 40.0f;
_rightViewRevealWidth = 260.0f;
_rightViewRevealOverdraw = 60.0f;
_rightViewRevealDisplacement = 40.0f;
_bounceBackOnOverdraw = YES;
_bounceBackOnLeftOverdraw = YES;
_stableDragOnOverdraw = NO;
_stableDragOnLeftOverdraw = NO;
_presentFrontViewHierarchically = NO;
_quickFlickVelocity = 250.0f;
_toggleAnimationDuration = 0.25;
_frontViewShadowRadius = 2.5f;
_frontViewShadowOffset = CGSizeMake(0.0f, 2.5f);
_frontViewShadowOpacity = 1.0f;
_userInteractionStore = YES;
_animationQueue = [NSMutableArray array];
_draggableBorderWidth = 0.0f;
}

Anbu.Karthik
- 82,064
- 23
- 174
- 143
-
-
1thank you .. but what if i need to do it run time means i will determine the device type and according to that i will display the size of the sidebar... @Anbu.Kartik – Premal Khetani Aug 07 '14 at 08:14
-
-
1@Anbu.Kartik yes either iphone or ipad i have to show side bar accordingly without changing in library (SWRevealViewController). – Premal Khetani Aug 07 '14 at 09:32
-
yes i know that but what if i want to do it manually, means i have requirement that have to show.... – Premal Khetani Aug 07 '14 at 10:08
-
4For iPad there is UISplitViewController so you dose not requires a SWRevealViewController for that.Search google for UISplitView. – Hiren Aug 08 '14 at 06:23
-
I am showing the slide menu on click of a particular button,but can I use the same button for a split view controller in case of device being iPad? – G.Abhisek Jan 06 '16 at 08:11
2
Just have an if statement to determine the correct size of the sidebar. something like this:
if(device == iPad)
_rearViewRevealWidth = 600.0f;
else if(device == iPhone)
_rearViewRevealWidth = 260.0f;

G3t Lucky
- 21
- 1
-
1yes i tried it but i want to use it from may front view controller not in SWRevealViewController class. – Premal Khetani Aug 08 '14 at 04:13
1
open the SWRevealViewController.m
file and then you get the _initDefaultProperties
Method.
- (void)_initDefaultProperties
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
float x=(appDelegate.windowWidth)*9/10; //windowWidth=self.window.bounds.size.width;
float y=x-260;
_frontViewPosition = FrontViewPositionLeft;
_rearViewPosition = FrontViewPositionRightMost;
_rightViewPosition = FrontViewPositionLeft;
_rearViewRevealWidth = x;
_rearViewRevealOverdraw = 60.0f+y;
_rearViewRevealDisplacement = 40.0f+y;
....
}

Suraj Sukale
- 1,778
- 1
- 12
- 19

Betsy
- 219
- 3
- 10
-
if you're using the SWRevealController pod, it might be better to define this value elsewhere instead of editing the pod code. In the controller that is the revealViewController's frontView, set the rearViewRevealWidth: if self.revealViewController() != nil { self.revealViewController().rearViewRevealWidth = self.view.frame.size.width * 0.80 } – mitrenegade Aug 27 '15 at 21:38
0
You can do something like this... When you have subclass from SWRevealViewController... call property for this problem and set as you want... Hope it's help someone...
self.rightViewRevealWidth = [UIScreen mainScreen].bounds.size.width * 0.9;

John
- 1
- 1