Giter Club home page Giter Club logo

kydrawercontroller's Introduction

KYDrawerController

Carthage compatible Pod Version Pod Platform Pod License Language Swift version

KYDrawerController is a side drawer navigation container view controller similar to Android.

  • Storyboard Support
  • AutoLayout Support

image.png storyboard.pngdrawer.gif

Installation

CocoaPods

KYDrawerController is available on CocoaPods. Add the following to your Podfile:

pod 'KYDrawerController'

Manually

Just add the Classes folder to your project.

Usage

(see sample Xcode project in /Example)

Code

import UIKit
import KYDrawerController

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        let mainViewController   = MainViewController()
        let drawerViewController = DrawerViewController()
        let drawerController     = KYDrawerController()
        drawerController.mainViewController = UINavigationController(
            rootViewController: mainViewController
        )
        drawerController.drawerViewController = drawerViewController
        
        /* Customize
        drawerController.drawerDirection = .Right
        drawerController.drawerWidth     = 200
        */
       
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = drawerController
        window?.makeKeyAndVisible()
        
        return true
    }

Storyboard

  1. Set the KYDrawerController to Custom Class of Initial ViewController.

usage1.png

  1. Connects the KYEmbedDrawerControllerSegue to DrawerViewController from KYDrawerController

usage2.png

  1. Connects the KYEmbedMainControllerSegue to DrawerViewController from KYDrawerController

usage3.png

  1. Set the SegueIdentifiers to inspector of KYDrawerController.

usage4.png

Open/Close Drawer

func setDrawerState(state: DrawerState, animated: Bool)

Delegate

optional func drawerController(_ drawerController: KYDrawerController, willChangeState state: KYDrawerController.DrawerState)
optional func drawerController(_ drawerController: KYDrawerController, didChangeState state: KYDrawerController.DrawerState)

Objective-C version

https://github.com/AustinChou/KYDrawerController-ObjC

License

This code is distributed under the terms and conditions of the MIT license.

kydrawercontroller's People

Contributors

akifumi avatar baidikoff avatar danielrosero avatar glennschmidt avatar ikesyo avatar petropavel13 avatar ripplek avatar timusus avatar waterlink avatar ykyouhei 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

kydrawercontroller's Issues

support swift 2.0

Hello.
He started to develop the application. Really liked the implementation of DrawerController. When will support Swift 2.0?

Incomplete Example

Hi. Why the example is separated into two sub-folders?
I'm a newbie to iOS and it's difficult to me to add this to my project...
I'm really confused.
Is there any complete tutorial?
Thanks.

Changing the frame Y

Hi !
First, it's a really nice project :)

Secondly, is it possible to easily change the position of the view ? I mean, the y origin.

Regards !

Drawer width autolayout

Hi kyo,

Thanks for your library, I'm wondering how can I use autolayout to update the drawer width ?

Thanks,
Ravi.

Error in Code

Hi I´ve set up the project of a uitabcontroller and the drawer as the issue #41, but i have a view controller with a button action performing the next code

    let drawer = self.navigationController!.parent?.parent as! KYDrawerController
    drawer.setDrawerState(.opened, animated: true)

im getting this error "Could not cast value of type 'KYDrawerController.KYDrawerController' (0x1012c3b00) to 'renti.KYDrawerController' (0x100cb5db0)."

Hide tabbar on push is not working.

Hide tabbar on push is not working.
TabbarController -> KYDrawerController - > MyUITableViewController -> push to detail view

I want to hide the UITabBar on the detail View. It does work.

How to change the main ViewController ?

Hi !

I don't know if this is possible, but I have a tableview on the drawer and after select some cell, I want to change the view controller. Is it possible?

Like change the controller that is initially set on the KYEmbedMainControllerSegue.

thanks a lot,

Filipe Faria

No way to navigate

I'm using a tableveiw for the drawer and want to send the user to a different view controller when they select a cell. How/where do I add code for this? I'm trying to do it in the didSelectRowAtIndexPath for the drawer class, but nothing works.

Setup drawer right side does not work

Hi. Thank you again for the awesome drawer.

I have a question. I want to setup drawer on right side. I am using your code example but it does not work ( when I clicked on Open button, No drawer displayed from right side)

drawerController.drawerDirection = .Right
drawerController.drawerWidth     = 200

Do I have do anything in order to make Right-Drawer work?

Thanks!

Animation Stutter

I'm using the storyboard approach. It works as expected, however the first time that you open the drawer either by swiping / programatically, the animation stutters a bit. Succeeding actions have little to no stutter. I'm on iPhone 6+ and I'm concerned that this would be an issue on older devices.

how to connect to tabBarController like you example

hi,thanks first

i want to use it with a tabBarController like this

let drawerViewController = LeftViewController()

drawerController.mainViewController = UINavigationController(
    rootViewController: configurationRootViewController()
)


drawerController.navigationController?.title = "tsing"; 
drawerController.drawerViewController = drawerViewController

/* Customize */
drawerController.drawerDirection = .Right
drawerController.drawerWidth     = 300

and the configurationRootViewController like

func configurationRootViewController() -> UITabBarController {

let todayListCtrl = UIStoryboard(name: "tsing", bundle: nil).instantiateViewControllerWithIdentifier("todaySB") as! TsingTaskController
todayListCtrl.tabBarItem.title = "today"
todayListCtrl.tabBarItem.image = UIImage(named: "tabbar_me")?.imageWithRenderingMode(.AlwaysOriginal)
todayListCtrl.tabBarItem.selectedImage = UIImage(named: "tabbar_meHL")?.imageWithRenderingMode(.AlwaysOriginal)
let todayNavigationController = UINavigationController(rootViewController: todayListCtrl)

// Create `chatsTableViewController`
let focusCtrl = UIStoryboard(name: "tsing", bundle: nil).instantiateViewControllerWithIdentifier("focusSB") as! TsingFocusController
focusCtrl.tabBarItem.title = "focus"
focusCtrl.tabBarItem.image = UIImage(named: "tabbar_discover")?.imageWithRenderingMode(.AlwaysOriginal)
focusCtrl.tabBarItem.selectedImage = UIImage(named: "tabbar_discoverHL")?.imageWithRenderingMode(.AlwaysOriginal)
let focusNavigationController = UINavigationController(rootViewController: focusCtrl)

let tabBarController = UITabBarController(nibName: nil, bundle: nil)
tabBarController.viewControllers = [todayNavigationController, focusNavigationController]


return tabBarController

}
TsingTaskController , TsingFocusController are UITableViewController

the app is run, but draw is not work, can give me some point how make tabBar work, thanks

another thing , how to set drawer title ?
drawerController.navigationController?.title = "tsing";
no effect

Drawer is not full height

I am getting this, but height is not full:
simulator screen shot may 16 2016 13 38 42

This is my setup:
screen shot 2016-05-16 at 13 41 06

On initial VC:
Class: KYDrawerController
Module: KYDrawerController
Attributes
mainSegueIdentifier: main
drawerSegueIdentifier: drawer

Everithing works but this height.
What can be problem here?

On first display, drawer controller animates vertically

On first run of

drawerController.setDrawerState(KYDrawerController.DrawerState.Opened, animated: true)

to open the drawer, the drawer view controller has a slight vertical animation. Presumably, this is from a CGRectZero frame or something similar. Calls to drawerController.drawerViewController?.loadView() or drawerController.drawerViewController?.view.layoutIfNeeded() before display have no effect.

Current workaround is to open and close the drawer without an animation after application has finished launching.

drawerController.setDrawerState(KYDrawerController.DrawerState.Opened, animated: false)
drawerController.setDrawerState(KYDrawerController.DrawerState.Closed, animated: false)

but creates warnings in the debugger

Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x7ff262ed9870>.
Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7ff26305f600>.

How to change first backround view

Hi! I need to change the first view when the drawer loads (and the user still hasn't selected any tab or even open the drawer menu). It depends on the view the menu loads, i.e.: if I load login, then the profile should appear and the drawer should be available. How can I do it so it shows the profile and not a white screen? Thank you very much and excelent job with this framework.

Drawer is not opening when coming from notification

I have integrated notifications in my ios app and on click of the notification i should go to the detail screen from list screen. The first list screen contains menu with KYDrawerController and the second screen is pushed into the main viewcontroller's stack. And everything works fine when i click the menu button its opening the menu button and when i click on some item in list its going to the detail screen but when I click on the notification which will directly take me to detail screen and coming back from that screen and clicking the menu button its not opening the menu drawer controller. And when i checked with the debugger the tap method is calling and its going into the KYDrawerController methods. Something fishy is happening here. Kindly help me with some hints why this is happening ?

Change in drawerDirection will not cause drawerViewController's position to change

out

Hi ykyouhei, I'm the author of KYDrawerController-ObjC. Someone send me a mail about this issue and I take sometime to investigate about this. See the above GIF for detailed information.

This implementation is like this:

- (IBAction)clickedOpen:(id)sender {
    KYDrawerController *elDrawer = (KYDrawerController*)self.navigationController.parentViewController;
    [elDrawer setDrawerDirection:KYDrawerControllerDrawerDirectionLeft];
    [elDrawer setDrawerState:KYDrawerControllerDrawerStateOpened animated:YES];
}

- (IBAction)clickedOpen1:(id)sender {
    KYDrawerController *elDrawer1 = (KYDrawerController*)self.navigationController.parentViewController;
    [elDrawer1 setDrawerDirection:KYDrawerControllerDrawerDirectionRight];
    [elDrawer1 setDrawerState:KYDrawerControllerDrawerStateOpened animated:YES];
}

This issue is cause by the update constraint process which drawerViewController’s frame is incorrect (not changed) after drawerDirection got changed. The constraints were changed correctly, but the frame of drawerViewController is not changed. Then performing the animation immediately will cause UI looks like the above.

Further more, I don't understand why you called updateConstraints instead of other methods like setNeedsUpdateConstraints or setNeedsLayout because we don't override updateConstraints method. updateConstraints will use UIView's default implementation which the behavior is not sure by myself.

Change from updateConstraints to layoutIfNeeded temporary solves this, but we still need further discussion.

How to update the main view with drawer menu

Hello Sir,
It's really a nice lib and easy to integrate slide menu, but here I am not able to update the main view from drawer view the view is always updated on drawer controller only.

For example, I have four views as follows:-
1- main
2- drawer
2.1 - in the drawer, there is two button menu ie signup and login
from the main menu I am able to access the drawer menu but when I used to click the menu button the view is updating on drawer menu only and the main view is as it is
any suggestion..!
Thank you

PopToRootViewController

Hi guys !

It's me again. I tried to put a row in my tableView in the menu to perform a log out.
So I do that :

self.navigationController?.popToRootViewControllerAnimated(true)

But it doesn't work. I tried to put a button, in the navigation bar, it worked.

I don't know how to manage :/

EDIT : In fact, I can't access to the navigationController, because when I perform print(self.navigationController?.viewControllers), it returns nil

Cheers

Passing a data from menu to ViewController

Hey mate , is it possible to pass data to our viewcontroller ? if my code is look like this

drawerController.performSegueWithIdentifier("main", sender: nil) drawerController.setDrawerState(.Closed, animated: true, block : nil)

i am unable to pass data to my viewController as the segue perform from the drawerController, can we enhance this issue ?

setDrawerState need to change the Layout subviews

Hello i have found one another issue the instead of Layouting the subviews of Maincontroller view, we have to layout subviews for the _ContainerView .. because thats animating the Maincontroller with weired animation

public func setDrawerState(state: DrawerState, animated: Bool,block:(()->Void?)?) {
        _containerView.hidden = false
        let duration: NSTimeInterval = animated ? _kDrawerAnimationDuration : 0

        UIView.animateWithDuration(duration,
            delay: 0,
            options: .CurveEaseOut,
            animations: { () -> Void in
                switch state {
                case .Closed:
                    self._drawerConstraint.constant     = 0
                    self._containerView.backgroundColor = UIColor(white: 0, alpha: 0)
                case .Opened:
                    let constant: CGFloat
                    switch self.drawerDirection {
                    case .Left:
                        constant = self.drawerWidth
                    case .Right:
                        constant = -self.drawerWidth
                    }
                    self._drawerConstraint.constant     = constant
                    self._containerView.backgroundColor = UIColor(
                        white: 0
                        , alpha: self._kContainerViewMaxAlpha
                    )
                }
                self._containerView.layoutIfNeeded() //Changed 
            }) { (finished: Bool) -> Void in
                if state == .Closed {
                    self._containerView.hidden = true
                }
                if block != nil {
                    block!()
                }
                self.delegate?.drawerController?(self, stateChanged: state)
        }
    }
so here i have changed the self._containerView.layoutIfNeeded() instead of self.view.layoutIfNeeded() //Changed

Drawer in tab bar

How do I implement a drawer in my tab bar, right now my implementation renders my tab bar above the drawer, is it even possible to use this framework in a tab bar in the first place?

Open/Close issue with storyborad configuration

if let drawerController = navigationController?.parentViewController as? KYDrawerController {
drawerController.setDrawerState(.Closed, animated: true)
or
drawerController.setDrawerState(.Opened, animated: true)
}

navigationController is nil here. So, drawer is not closing / opening.

pan gesture is working perfectly.

main view controller is tabbarcontroller

Drawer width smaller in status bar

HI,

I followed the Interface Builder instruction, but i got this strange render and i didn't found anything to solve this

capture d ecran 2016-07-27 a 18 33 23

The KYDrawerController is the first controller after a modal segue (i can't place it at entry point because i've the login screen) and the problem appear with and without drawer width setted

Strange behavior

Her's how I've implemented the library :

        let drawerController     = KYDrawerController()

        drawerController.mainViewController = UINavigationController(
            rootViewController: tabBarController
        )
        drawerController.drawerViewController = menuController
        drawerController.drawerDirection = .Right

        /* Customize
        drawerController.drawerDirection = .Right
        drawerController.drawerWidth     = 200
        */

        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = drawerController
        window?.makeKeyAndVisible()

strange

As you can see in the gif normally the menu should appear on right not left and also the tab bar color have changed normally it's orange not white.

Provide same code example

HI,Thanks for your library.
How to use add drawer via code only,because in readme file,there is explanation only for storyboard and also "code" example is totally different.So can you please explain use of drawer menu via code as explained for "storyboard".

Support for iOS 10

I have upgraded my system and Xcode to 8.
When I am building app in iOS 10 with swift 3. KYDrawerController giving issue.

Can you please provide me support for swift 3.

Support Example For using with UITabBarController?

First of all,Thanks for all of your hard work.Really love it to try.
Your gif image show that your view controller is also supported for embedding with UITabBarController.

But,I really need some help with demo project.So,Any Help with UITabBarController?Because i want to build App like Google+ current version for now.Plus,I want to navigate directly from left menu to uitabbar item.
Eg.,If I tapped one of the menu from left menu,it navigate to appropriate UITabBarItem

If you have anytime,can you take a look at this?because we all have our circumstances,our life.
So,Any Demo Example for that?Storyboard or code?

Any Help?Thanks.

Animation issue - Changing drawerViewController and direction respectively.

Hi,

Thanks for the awesome project. Even more for sharing it with the community.

My scenario:

  1. One Naviagtion controller in center as mainViewController.
  2. Two side bar menu controller, i.e. left and right.
  3. In Navigation bar, I have two bar button items on each side. One(on the left) to reveal 'main' menu from left and the other(on the right) to reveal 'sub' menu from right.

Since the orignal 'KYdrawerController' project only supports one side for the moment, so I am using a workaround for now.

I keep both side view controllers ready. Whenever user presses either of the button in navigation bar. I change the drawerViewController and drawerDirection properties with respective viewcontroller and direction.

It is working fine. The issue is when user presses the right menu button for the first time, it seems the viewcontroller takes a flight from far left side to the far right side first, then reveals itself from there.

Code for setting leftsidebar

screen shot 2015-10-28 at 3 58 57 pm

Code for setting rightsidebar

screen shot 2015-10-28 at 3 58 47 pm

Note: 1. It only happens for the first time. After that it runs fine.
2. I am using swift files in objective C project. (Dont think it matters though.)

Please suggest something.

Thanks.

Delegate by drawer state

Hi,

KYDrawerController is nice drawer.
but needed delegate, by drawer state like DrawerState.Opened or DrawerState.Closed

func kyDrawerControllerStateChanged(state: DrawerState)

Prevent menu from opening

In order to prevent the menu from opening in specific ViewControllers I had to set the menu width to 0 and set it to .Closed when the delegate tells me it's been opened.

Besides not being elegant, the dark overlay appears for a slight moment.

Any other way around it?

Thanks.

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.