John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 988 forks source link

width of rear view controller #109

Closed jdrukman closed 10 years ago

jdrukman commented 11 years ago

The rear view controller width is returning 320, even though it is partially obscured by the front. Is there a way to get the correct width? (If it matters, rear is a UITableViewController because it's using a static table from a storyboard.)

tzeejay commented 11 years ago

the rear is obscured to make it look like the front view controller lays over it physically. Its just a visual effect that is set to yes by default. The code you are looking for is:

// Defines the radius of the front view's shadow, default is 2.5f @property (assign, nonatomic) CGFloat frontViewShadowRadius;

// Defines the radius of the front view's shadow offset default is {0.0f,2.5f} @property (assign, nonatomic) CGSize frontViewShadowOffset;

//Defines the front view's shadow opacity, default is 1.0f @property (assign, nonatomic) CGFloat frontViewShadowOpacity;

Tweak this so make the shadow bigger or smaller or change its alpha.

What are you trying to do with the correct width? I don't understand why the width of the rear view would matter in any way since it is not fully shown at any time (only when you use FrontViewLeftSideMostRemoved. Like a presentation mode).

jdrukman commented 11 years ago

My rear controller is a table with a search bar in the header, and icons on the right of the cell (see Facebook, Rdio, Wunderlist, Gmail, probably 1000 other apps). In order to position everything within the cell properly, and ensure that the search bar isn't cut off, I need to know the visible width. I made it work by hardcoding the table width to 260 in viewWillLayoutSubviews, but this seems like a gross hack.

John-Lluch commented 11 years ago

Hi jdrukman, you have a property telling you the reveal width so you don't need to hard core anything.

Also you have delegates that tell you what position the front controller is at any time, so you should be able to track this accordingly.

You can also place code inside of the reveal animation block by implementing the animateToPosition delegate so your animations go in sync with the revealViewController animations. I added this delegate long ago precisely to help developers to do exactly what you want.

Finally, I would never recommend a viewController changing the width of its view as this is exclusive responsibility of their parents. Instead you should implement your own layout on your controller view and adjust your subviews accordingly in your swrevealViewController delegate implementations.

I Hope this helps.

Thanks

jdrukman commented 11 years ago

Somehow I missed rearViewRevealWidth when perusing the .h before.

Is there any way to access self.revealViewController when using UITableViewController?

John-Lluch commented 11 years ago

if your UITableViewController is already on the hierarchy then self.revealViewController should already deliver what it is supposed to.

jdrukman commented 11 years ago

Property 'revealViewController' not found on object of type 'SRLeftPaneViewController*'

Never mind - I figured it out. Just #importing SWRevealViewController.h is enough.

Thanks for a great class. It saved me a ton of time!