pkluz / PKRevealController

PKRevealController is a delightful view controller container for iOS, enabling you to present multiple controllers on top of one another.
Other
3.85k stars 659 forks source link

How to limit rear view width? #22

Closed hohl closed 12 years ago

hohl commented 12 years ago

I am using a table view as rear view. But the table view is as width as the screen, so the right part of the table view is invisible, because it is overlapped by front view. Is there be a chance to limit the width of the rear view, to only the visible width?

Btw. nice project!

pkluz commented 12 years ago

Of course you can do that but that's not something library-dependent. In your own RearViewController.xib file simply squeeze the tableView to suit your needs and provide a matching background (because if your finger pans further than the edge it reveals a few more pixels before it snaps back.)

Easiest way is to simply have your RearViewController.xib made up of a a UIView which contains a UITableView (which is say,...set to 80% of the UIView's with). Thus your container is a UIViewController which conforms to UITableViewDelegate/DataSource protocols and not a UITableViewController directly although that's possible as well.

If you REALLY wish to alter the entire behavior of the Controller you can in fact do that like this:

  1. Open ZUUIRevealController.m and go to the viewDidLoad: method.
  2. Adjust this line: self.rearView = [[[UIView alloc] initWithFrame:self.view.bounds] autorelease]; with a frame that suits your needs.

Although I do not recommend this.

kerrishotts commented 12 years ago

This /works/, not sure how well it would be looked upon, however:

in your -viewDidUnload method: CGRect newFrame = self.navigationController.view.frame; newFrame.size.width = 320; // whatever width you want self.navigationController.view.frame = newFrame;

The same issue applies here, that if you make it too narrow, you can see through to the window background when you slide it a few pixels beyond the width of the controller.

/If/ you do this, be sure to make the navigationController's view not autoresizable for the width. Otherwise /very/ funny things happen when orientations change.