Git Product home page Git Product logo

twtsidemenuviewcontroller's Introduction

TWTSideMenuViewController

Build Status

One of the most common implementations of menu views has been the "Side Drawer", "basement", or "Side Menu" made popular in apps such as Facebook and Path. When the user taps to open the side menu the user's main context slides to the right (or left in some implementations) to display another view below. This works well in iOS 6 and before. What does it mean for iOS 7?

With iOS 7, apps are encouraged to use the whole screen and not rely on the 20pt status bar to be outside of the plane of your app. This breaks the existing side bar idea in that the status bar now lives over two view contexts with a single style.

Bad Side Bar

Working with the team at Luvocracy, we needed to find a way to show a side menu for our iOS 7 release. Many designers on Dribbble began looking at a new approach for side bars. Inspired by this we worked up a quick prototype that slides the view to the right and scales revealing the menu as seen in the dribbble samples above. Moving forward from this idea and inspired by other ideas from iOS 7 we changed it from a slide to more of a viewport change.

SideMenuViewController

Usage

TWTSideMenuViewController is implemented using a single parent view controller that manages your menu and main views as child view controllers. To set it up, initialize a new instance of TWTSideMenuViewController and supply a menu view controller and a main view controller.

  // application:didFinishLaunchingWithOptions:

  self.menuViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
  self.mainViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
  
  // create a new side menu
  self.sideMenuViewController = [[TWTSideMenuViewController alloc] initWithMenuViewController:self.menuViewController mainViewController:[[UINavigationController alloc] initWithRootViewController:self.mainViewController]];

  // specify the shadow color to use behind the main view controller when it is scaled down.
  self.sideMenuViewController.shadowColor = [UIColor blackColor];

  // specify a UIOffset to offset the open position of the menu
  self.sideMenuViewController.edgeOffset = UIOffsetMake(18.0f, 0.0f);

  // specify a scale to zoom the interface โ€” the scale is 0.0 (scaled to 0% of it's size) to 1.0 (not scaled at all). The example here specifies that it zooms so that the main view is 56.34% of it's size in open mode. 
  self.sideMenuViewController.zoomScale = 0.5634f;

  // set the side menu controller as the root view controller
  self.window.rootViewController = self.sideMenuViewController;

Later, when you need to change what is in the main view controller's context you can simply set the view controller with the convenience method:

  // All views presented in a side menu view controller have access to the side menu directly. Much like the way UINavigationController works. To swap to a new view controller simply set the main view controller:

  [self.sideMenuViewController setMainViewController:controller animated:YES closeMenu:YES];

TODO

  • Find additional requirements as the library is used in additional apps. (This initial version was built to meet the needs of a single app).
  • Add Tests

Requirements

  • Base SDK: iOS 7
  • Deployment Target: iOS 6+

Contact

TWTSideMenuViewController was created by Two Toasters in the development of Luvocracy.

License

Available under the MIT License. See the LICENSE file for more.

twtsidemenuviewcontroller's People

Contributors

armintelker avatar chrisperkins avatar danielrhammond avatar designatednerd avatar tomburns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twtsidemenuviewcontroller's Issues

Right SideMenu

i want to open the SideMenu from the right not the left what should i change in the code ?

Storyboards....scrolling too!

Could you post an example with storyboards?

Also, in the luvocracy app, the menu appears to be a tableview, is this correct? If not, how would I get the buttons to scroll??

iPad Landscape issue

If the app launches in landscape mode on the iPad, when the user navigates to the menu view controller there is a white padding on the sides. Moving to portrait from landscape and back resolves the issue.
bug

Too many calls to addChildViewController

Hi,
First of all, a million thanks for this great piece of code, no more hamburger hunt for me ;)

Unless I'm missing something, I think there are too many addChildViewController calls, resulting in the menuViewController "diding"MoveToParentViewController 3 times: first to , then to (null), then back to .
Commenting the calls to addViewController: in commonInitialization and simply setting the sideMenuViewController property of the two viewControllers there is my quick working fix. Or is it?

iOS 8 support

The open/close animation is jerky on iOS8. Appreciate any suggestions to solve this issue.

UISplitViewController

Using the TWTSideViewController with a UISplitViewController as the main view controller causes the root view controller of the split view to be shown as part of the resized main view when the menu is open. Using the detail view controller of the split view controller as the main view does not solve the problem because the split view delegate methods are no longer called in this configuration.

Support for Arabic language

Hi,

Do you provide support for Arabic language.? As it is right to left will the layout of sidemenu change to right in Arabic or any RTL language?

I have an urgent requirement on this.

Thanks.

wrong initial menuViewController transform ?

The call to updateMenuViewWithTransform in viewDidLoad results in the menuViewController's view being pushed to far to the left in the very first run, subsequent transforms are ok (the starting position of the menuViewController's view in the closed menu is ok, past the first open/close). Actually, I'm not sure if this is a bug or a feature? For my case, I dont use a too wide background image and the background color appearing behind in the first openning of the menu was just not ok, i commented the call. I'm I missing something?

Misaligned frame when appearing in landscape

This is a bit hard to replicate.

First, you present a modal VC in from the side menu in portrait orientation.
This modal VC only support portrait.

Then if you hold the phone so that it would immediately rotate to landscape as soon as the modal vc is dismiised, the entire frame is messed up.

At this point, you can close the side menu, but the main VC won't fill the entire screen. Occasionally it might be too wide or too thin.

http://imgur.com/ukFJoYP
http://imgur.com/SwrCDQC

The green part in this picture is the side menu's background, which should not be visible at all.
The only way to undo after this happen is to restart the app.

Change side menu controller on the fly?

First of all, thanks for the great control. I'll be using it in my upcoming chat app. I've done a little customization and added a second menu controller (called right menu controller) so that the user can swipe left and right for different menus. My only issue right now is switching out the menu controllers on the fly when the user loads different pages. For instance, on one page I want to display all of their friends, but on another page I want it to display search criteria.

Could you point me in the right direction of how to do this? I tried swapping out the view controller in the mainController's viewWillAppear method but it didn't give the desired effect. Thank you.

SideMenu on all ViewControllers

I was wondering how I can have the side menu available in every ViewController of the app, right now when I modally push another ViewController and "open" the side menu it opens in the root view controller =/ I know this because when I undwind to the root the side menu is opened.

Installing via CocoaPods

Is this the correct way to install your library with CocoaPods?

$ echo "pod 'TWTSideMenuViewController'" >> Podfile
$ pod install
Analyzing dependencies
[!] Unable to find a specification for TWTSideMenuViewController.

private repo I guess?
$ pod repo add TWTSideMenuViewController https://github.com/twotoasters/TWTSideMenuViewController.git

I query pods and it's showing it now:
$ pod list | grep TWT
TWTSideMenuViewController
TWTSideMenuViewController-Sample
TWTSideMenuViewController-Sample.xcodeproj
TWTSideMenuViewController-SampleTests

$ pod install
[!] Unable to satisfy the following requirements:

  • TWTSideMenuViewController required by Podfile

I'm new to CocoaPods so maybe this is an issue with that.

I can see my side menu in the background

While the animation is happening I can see elements of my side menu in the background. Almost like the side menu itself is saved as the background image of the window.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.